« get me outta code hell

content, page, util: general contributions usage cleanup - 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>2024-06-02 10:55:38 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:06 -0300
commit4aa153ebae1360e390b9d372fabf457ee8b21705 (patch)
treea1cff366b439550227fa6ef7b9b4f6c575e51daf /src/util
parent5550f8ec487c3cae87de36f4e0c1fe9d6df8e36c (diff)
content, page, util: general contributions usage cleanup
Diffstat (limited to 'src/util')
-rw-r--r--src/util/wiki-data.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index f8ab3ef3..c0cb5418 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -1,6 +1,6 @@
 // Utility functions for interacting with wiki data.
 
-import {accumulateSum, empty} from './sugar.js';
+import {accumulateSum, empty, unique} from './sugar.js';
 import {sortByDate} from './sort.js';
 
 // This is a duplicate binding of filterMultipleArrays that's included purely
@@ -138,11 +138,20 @@ export function getAllTracks(albumData) {
 }
 
 export function getArtistNumContributions(artist) {
-  return (
-    (artist.tracksAsAny?.length ?? 0) +
-    (artist.albumsAsCoverArtist?.length ?? 0) +
-    (artist.flashesAsContributor?.length ?? 0)
-  );
+  return accumulateSum(
+    [
+      unique(
+        ([
+          artist.trackArtistContributions,
+          artist.trackContributorContributions,
+          artist.trackCoverArtistContributions,
+        ]).flat()
+          .map(({thing}) => thing)),
+
+      artist.albumCoverArtistContributions,
+      artist.flashContributorContributions,
+    ],
+    ({length}) => length);
 }
 
 export function getFlashCover(flash, {to}) {