« get me outta code hell

autumnal polish haul - 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:
author(quasar) nebula <towerofnix@gmail.com>2020-10-10 12:09:24 -0300
committer(quasar) nebula <towerofnix@gmail.com>2020-10-10 12:09:24 -0300
commitf017dfe9c87bdf29430a26aa2b441d56e62c9195 (patch)
treea78888b3171e71904d20539069f2c6b6c1828719 /common.js
parentb572dccabdf413bad8b58fc6de1a8357a9df9671 (diff)
autumnal polish haul
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>'))
 };