« get me outta code hell

content: generateArtistInfoPage: tidy up querying - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-30 17:09:31 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-30 17:11:00 -0300
commit84e1f947c9ac17ab075348ea386d43c17af66435 (patch)
treeae6e8badd21244cca979fdbeae1a487a65caee5a /src/content
parentc0d76a612f3a1db99c60f494d2bdcc05fa7c6679 (diff)
content: generateArtistInfoPage: tidy up querying
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateArtistInfoPage.js43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/content/dependencies/generateArtistInfoPage.js b/src/content/dependencies/generateArtistInfoPage.js
index 6956244b..1f6c66fc 100644
--- a/src/content/dependencies/generateArtistInfoPage.js
+++ b/src/content/dependencies/generateArtistInfoPage.js
@@ -30,7 +30,27 @@ export default {
 
   query(sprawl, artist) {
     return {
-      allTracks: unique([...artist.tracksAsArtist, ...artist.tracksAsContributor]),
+      // Even if an artist has served as both "artist" (compositional) and
+      // "contributor" (instruments, production, etc) on the same track, that
+      // track only counts as one unique contribution.
+      allTracks:
+        unique([...artist.tracksAsArtist, ...artist.tracksAsContributor]),
+
+      // Artworks are different, though. We intentionally duplicate album data
+      // objects when the artist has contributed some combination of cover art,
+      // wallpaper, and banner - these each count as a unique contribution.
+      allArtworks: [
+        ...artist.albumsAsCoverArtist,
+        ...artist.albumsAsWallpaperArtist,
+        ...artist.albumsAsBannerArtist,
+        ...artist.tracksAsCoverArtist,
+      ],
+
+      // Banners and wallpapers don't show up in the artist gallery page, only
+      // cover art.
+      hasGallery:
+        !empty(artist.albumsAsCoverArtist) ||
+        !empty(artist.tracksAsCoverArtist),
     };
   },
 
@@ -68,30 +88,17 @@ export default {
       tracks.groupInfo = relation('generateArtistGroupContributionsInfo', query.allTracks);
     }
 
-    if (
-      !empty(artist.albumsAsCoverArtist) ||
-      !empty(artist.albumsAsWallpaperArtist) ||
-      !empty(artist.albumsAsBannerArtist) ||
-      !empty(artist.tracksAsCoverArtist)
-    ) {
+    if (!empty(query.allArtworks)) {
       const artworks = sections.artworks = {};
       artworks.heading = relation('generateContentHeading');
       artworks.list = relation('generateArtistInfoPageArtworksChunkedList', artist);
+      artworks.groupInfo =
+        relation('generateArtistGroupContributionsInfo', query.allArtworks);
 
-      if (!empty(artist.albumsAsCoverArtist) || !empty(artist.tracksAsCoverArtist)) {
+      if (query.hasGallery) {
         artworks.artistGalleryLink =
           relation('linkArtistGallery', artist);
       }
-
-      // We intentionally duplicate album data objects when the artist has contributed
-      // at least two of cover art / wallpaper / banner! These each count as one.
-      artworks.groupInfo =
-        relation('generateArtistGroupContributionsInfo', [
-          ...artist.albumsAsCoverArtist,
-          ...artist.albumsAsWallpaperArtist,
-          ...artist.albumsAsBannerArtist,
-          ...artist.tracksAsCoverArtist,
-        ]);
     }
 
     if (sprawl.enableFlashesAndGames && !empty(artist.flashesAsContributor)) {