« get me outta code hell

content, upd8, yaml: adapt to combined artistData - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-30 10:52:20 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-30 14:30:05 -0400
commit7fbc5b87ed05bce433ed959ca18119b72835ee41 (patch)
treea9b96e8e575a927ed2e4a7a16036fce88b9a4a1d /src/data
parentf12bbec38694c30a79655a0be54768cd83f1efb5 (diff)
content, upd8, yaml: adapt to combined artistData
Diffstat (limited to 'src/data')
-rw-r--r--src/data/yaml.js28
1 files changed, 15 insertions, 13 deletions
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;