« 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/content/dependencies/listArtistsByGroup.js
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/content/dependencies/listArtistsByGroup.js
parent5550f8ec487c3cae87de36f4e0c1fe9d6df8e36c (diff)
content, page, util: general contributions usage cleanup
Diffstat (limited to 'src/content/dependencies/listArtistsByGroup.js')
-rw-r--r--src/content/dependencies/listArtistsByGroup.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/content/dependencies/listArtistsByGroup.js b/src/content/dependencies/listArtistsByGroup.js
index f221fe8c..0bf9dd2d 100644
--- a/src/content/dependencies/listArtistsByGroup.js
+++ b/src/content/dependencies/listArtistsByGroup.js
@@ -1,10 +1,12 @@
 import {sortAlphabetically} from '#sort';
+
 import {
   empty,
   filterByCount,
   filterMultipleArrays,
   stitchArrays,
   transposeArrays,
+  unique,
 } from '#sugar';
 
 export default {
@@ -32,10 +34,27 @@ export default {
     // (interesting) groups that each of each artists' things belongs to.
     const artistThingGroups =
       artists.map(artist =>
-        ([...artist.albumsAsAny.map(album => album.groups),
-          ...artist.tracksAsAny.map(track => track.album.groups)])
-            .map(groups => groups
-              .filter(group => interestingGroups.includes(group))));
+        ([
+          (unique(
+            ([
+              artist.albumArtistContributions,
+              artist.albumCoverArtistContributions,
+              artist.albumWallpaperArtistContributions,
+              artist.albumBannerArtistContributions,
+            ]).flat()
+              .map(({thing}) => thing)
+          )).map(album => album.groups),
+          (unique(
+            ([
+              artist.trackArtistContributions,
+              artist.trackContributorContributions,
+              artist.trackCoverArtistContributions,
+            ]).flat()
+              .map(({thing}) => thing)
+          )).map(track => track.album.groups),
+        ]).flat()
+          .map(groups => groups
+            .filter(group => interestingGroups.includes(group))));
 
     const [artistsByGroup, countsByGroup] =
       transposeArrays(interestingGroups.map(group => {