« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageTracksChunkItem.js')
-rw-r--r--src/content/dependencies/generateArtistInfoPageTracksChunkItem.js65
1 files changed, 17 insertions, 48 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js b/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
index 3d6e274b..22a4a228 100644
--- a/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
+++ b/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
@@ -1,60 +1,23 @@
 import {sortAlbumsTracksChronologically} from '#sort';
 import {empty} from '#sugar';
+import {selectRepresentativeArtistContributorContribs} from '#wiki-data';
 
 export default {
-  query(artist, contribs) {
+  query(artist, contribs, chunkContribs) {
     const query = {};
 
-    // TODO: Very mysterious what to do if the set of contributions is,
-    // in total, associated with more than one thing. No design yet.
     query.track =
       contribs[0].thing;
 
-    const creditedAsNormalArtist =
-      contribs
-        .some(contrib =>
-          contrib.thingProperty === 'artistContribs' &&
-         !contrib.isFeaturingCredit);
-
-    const creditedAsContributor =
-      contribs
-        .some(contrib => contrib.thingProperty === 'contributorContribs');
-
-    const annotatedContribs =
-      contribs
-        .filter(contrib => !empty(contrib.annotationParts));
-
-    const annotatedArtistContribs =
-      annotatedContribs
-        .filter(contrib => contrib.thingProperty === 'artistContribs');
-
-    const annotatedContributorContribs =
-      annotatedContribs
-        .filter(contrib => contrib.thingProperty === 'contributorContribs');
-
-    // Don't display annotations associated with crediting in the
-    // Contributors field if the artist is also credited as an Artist
-    // *and* the Artist-field contribution is non-annotated. This is
-    // so that we don't misrepresent the artist - the contributor
-    // annotation tends to be for "secondary" and performance roles.
-    // For example, this avoids crediting Marcy Nabors on Renewed
-    // Return seemingly only for "bass clarinet" when they're also
-    // the one who composed and arranged Renewed Return!
-    if (
-      creditedAsNormalArtist &&
-      creditedAsContributor &&
-      empty(annotatedArtistContribs)
-    ) {
-      query.displayedContributions = null;
-    } else if (
-      !empty(annotatedArtistContribs) ||
-      !empty(annotatedContributorContribs)
-    ) {
-      query.displayedContributions = [
-        ...annotatedArtistContribs,
-        ...annotatedContributorContribs,
-      ];
-    }
+    query.date =
+      contribs[0].date;
+
+    query.anyItemsExpresslyDated =
+      chunkContribs.flat()
+        .some(contrib => +contrib.date !== +query.track.album.date);
+
+    query.displayedContributions =
+      selectRepresentativeArtistContributorContribs(contribs);
 
     // It's kinda awkward to perform this chronological sort here,
     // per track, rather than just reusing the one that's done to
@@ -112,6 +75,11 @@ export default {
   }),
 
   data: (query) => ({
+    date:
+      (query.anyItemsExpresslyDated
+        ? query.date
+        : null),
+
     duration:
       query.track.duration,
 
@@ -146,6 +114,7 @@ export default {
               relations.trackListItem.slots({
                 showArtists: 'auto',
                 showDuration: slots.showDuration,
+                showDate: data.date,
               })),
         }),
     }),