« get me outta code hell

content: gAIPTracksChunkedList: avoid obscuring as-artist credit - 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>2024-03-04 10:22:38 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-03-04 10:22:38 -0400
commitdca169fbf6c6bf09f3ad4e5bf3b153b7bd83f1f9 (patch)
treef4571d7ae2169a3d05ce9e62160282782be4ee77 /src/content
parente1ab9bbf56113257c9d0818912c95f62c458f1e3 (diff)
content: gAIPTracksChunkedList: avoid obscuring as-artist credit
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateArtistInfoPageTracksChunkedList.js72
1 files changed, 64 insertions, 8 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js
index d68eba3f..f003779d 100644
--- a/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageTracksChunkedList.js
@@ -47,17 +47,23 @@ export default {
     const tracksAsArtistAndContributorContribs =
       tracksAsArtistAndContributor
         .map(track => [
-          ...track.artistContribs,
-          ...track.contributorContribs,
+          ...
+            track.artistContribs
+              .map(contrib => ({...contrib, kind: 'artist'})),
+          ...
+            track.contributorContribs
+              .map(contrib => ({...contrib, kind: 'contributor'})),
         ]);
 
     const tracksAsArtistOnlyContribs =
       tracksAsArtistOnly
-        .map(track => track.artistContribs);
+        .map(track => track.artistContribs
+          .map(contrib => ({...contrib, kind: 'artist'})));
 
     const tracksAsContributorOnlyContribs =
       tracksAsContributorOnly
-        .map(track => track.contributorContribs);
+        .map(track => track.contributorContribs
+          .map(contrib => ({...contrib, kind: 'contributor'})));
 
     const tracksAsArtistAndContributorEntries =
       processTrackEntries({
@@ -144,10 +150,60 @@ export default {
         query.chunks.map(({chunk}) =>
           chunk
             .map(({contribs}) =>
-              contribs
-                .filter(({who}) => who === artist)
-                .filter(({what}) => what)
-                .map(({what}) => what))
+              contribs.filter(({who}) => who === artist))
+            .map(ownContribs => ({
+              creditedAsArtist:
+                ownContribs
+                  .some(({kind}) => kind === 'artist'),
+
+              creditedAsContributor:
+                ownContribs
+                  .some(({kind}) => kind === 'contributor'),
+
+              annotatedContribs:
+                ownContribs
+                  .filter(({what}) => what),
+            }))
+            .map(({annotatedContribs, ...rest}) => ({
+              ...rest,
+
+              annotatedArtistContribs:
+                annotatedContribs
+                  .filter(({kind}) => kind === 'artist'),
+
+              annotatedContributorContribs:
+                annotatedContribs
+                  .filter(({kind}) => kind === 'contributor'),
+            }))
+            .map(({
+              creditedAsArtist,
+              creditedAsContributor,
+              annotatedArtistContribs,
+              annotatedContributorContribs,
+            }) => {
+              // 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 (
+                creditedAsArtist &&
+                creditedAsContributor &&
+                empty(annotatedArtistContribs)
+              ) {
+                return [];
+              }
+
+              return [
+                ...annotatedArtistContribs,
+                ...annotatedContributorContribs,
+              ];
+            })
+            .map(contribs =>
+              contribs.map(({what}) => what))
             .map(contributions =>
               (empty(contributions)
                 ? null