From 7fbc5b87ed05bce433ed959ca18119b72835ee41 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 30 Jan 2024 10:52:20 -0400 Subject: content, upd8, yaml: adapt to combined artistData --- src/data/yaml.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/data/yaml.js') diff --git a/src/data/yaml.js b/src/data/yaml.js index 0f7f06f0..795eddf1 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -1118,8 +1118,22 @@ export function filterReferenceErrors(wikiData) { return recursive(obj, keys); } - const aggregate = openAggregate({message: `Errors validating between-thing references in data`}); const boundFind = bindFind(wikiData, {mode: 'error'}); + + const artistAliasData = wikiData.artistData.filter(artist => artist.isAlias); + const findArtistOrAlias = artistRef => { + const alias = find.artistIncludingAliases(artistRef, artistAliasData, {mode: 'quiet'}); + if (alias) { + // No need to check if the original exists here. Aliases are automatically + // created from a field on the original, so the original certainly exists. + const original = alias.aliasedArtist; + throw new Error(`Reference ${colors.red(artistRef)} is to an alias, should be ${colors.green(original.name)}`); + } + + return boundFind.artist(artistRef); + }; + + const aggregate = openAggregate({message: `Errors validating between-thing references in data`}); for (const [thingDataProp, propSpec] of referenceSpec) { const thingData = getNestedProp(wikiData, thingDataProp); @@ -1165,18 +1179,6 @@ export function filterReferenceErrors(wikiData) { let findFn; - const findArtistOrAlias = artistRef => { - const alias = find.artist(artistRef, wikiData.artistAliasData, {mode: 'quiet'}); - if (alias) { - // No need to check if the original exists here. Aliases are automatically - // created from a field on the original, so the original certainly exists. - const original = alias.aliasedArtist; - throw new Error(`Reference ${colors.red(artistRef)} is to an alias, should be ${colors.green(original.name)}`); - } - - return boundFind.artist(artistRef); - }; - switch (findFnKey) { case '_artTag': findFn = boundFind.artTag; -- cgit 1.3.0-6-gf8a5