« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/common.js
diff options
context:
space:
mode:
Diffstat (limited to 'common.js')
-rw-r--r--common.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/common.js b/common.js
index 83970d3e..02dd3c2b 100644
--- a/common.js
+++ b/common.js
@@ -77,14 +77,20 @@ const C = {
     // "directories", we just reformat the artist's name.
     getArtistDirectory: artistName => C.getKebabCase(artistName),
 
-    getArtistNumContributions: (artistName, {allTracks, albumData, flashData}) => [
-        ...allTracks.filter(track =>
-            track.artists.includes(artistName) ||
-            [...track.contributors, ...track.coverArtists || []].some(({ who }) => who === artistName)),
+    getThingsArtistContributedTo: (artistName, {allTracks, albumData, flashData}) => [
+        ...allTracks.filter(track => [
+            ...track.artists,
+            ...track.contributors,
+            ...track.coverArtists || []
+        ].some(({ who }) => who === artistName)),
         ...flashData.filter(flash => (flash.contributors || []).some(({ who }) => who === artistName)),
         ...albumData.filter(album =>
             (album.coverArtists || []).some(({ who }) => who === artistName))
-    ].length,
+    ],
+
+    getArtistNumContributions: (artistName, {allTracks, albumData, flashData}) => (
+        C.getThingsArtistContributedTo(artistName, {allTracks, albumData, flashData}).length
+    ),
 
     getArtistCommentary: (artistName, {justEverythingMan}) => justEverythingMan.filter(thing => thing.commentary && thing.commentary.replace(/<\/?b>/g, '').includes('<i>' + artistName + ':</i>'))
 };