« get me outta code hell

pre-writes: listings - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-02-17 23:23:35 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-02-17 23:25:59 -0400
commitf26ad2e27e9c7ca61b6ae5e9b3587786d911a2df (patch)
treea611d91cab993d84cda1dd81af7be741295e248a /src/util
parentf8557485ac06a7b2527c50dcf638497212678a16 (diff)
pre-writes: listings
Diffstat (limited to 'src/util')
-rw-r--r--src/util/find.js6
-rw-r--r--src/util/wiki-data.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/util/find.js b/src/util/find.js
index a9af238..872b3b7 100644
--- a/src/util/find.js
+++ b/src/util/find.js
@@ -25,6 +25,10 @@ function findHelper(keys, dataProp, findFns = {}) {
 
         const data = wikiData[dataProp];
 
+        if (!data) {
+            throw new Error(`Expected data to be present`);
+        }
+
         const found = (key
             ? byDirectory(ref, data, quiet)
             : byName(ref, data, quiet));
@@ -76,12 +80,12 @@ function matchTagName(ref, data, quiet) {
 const find = {
     album: findHelper(['album', 'album-commentary'], 'albumData'),
     artist: findHelper(['artist', 'artist-gallery'], 'artistData'),
+    artTag: findHelper(['tag'], 'artTagData', {byName: matchTagName}),
     flash: findHelper(['flash'], 'flashData'),
     group: findHelper(['group', 'group-gallery'], 'groupData'),
     listing: findHelper(['listing'], 'listingSpec'),
     newsEntry: findHelper(['news-entry'], 'newsData'),
     staticPage: findHelper(['static'], 'staticPageData'),
-    tag: findHelper(['tag'], 'artTagData', {byName: matchTagName}),
     track: findHelper(['track'], 'trackData')
 };
 
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 2f705f9..41071d1 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -129,9 +129,9 @@ export function getAllTracks(albumData) {
 
 export function getArtistNumContributions(artist) {
     return (
-        artist.tracks.asAny.length +
-        artist.albums.asCoverArtist.length +
-        (artist.flashes ? artist.flashes.asContributor.length : 0)
+        (artist.tracksAsAny?.length ?? 0) +
+        (artist.albumsAsCoverArtist?.length ?? 0) +
+        (artist.flashesAsContributor?.length ?? 0)
     );
 }