« get me outta code hell

content: gAIPOtherArtistLinks: use associatedContributions - 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-04-10 19:39:41 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:05 -0300
commit019e351a9560b09256dfaf99fea9252029df1701 (patch)
tree16cf9e0c68ad88da2220036a1fd3d92d791d6f67 /src/content
parentdd5f7fe008a8b7c207e0f82255fedd1442f41b04 (diff)
content: gAIPOtherArtistLinks: use associatedContributions
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js2
-rw-r--r--src/content/dependencies/generateArtistInfoPageChunkItem.js4
-rw-r--r--src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js1
-rw-r--r--src/content/dependencies/generateArtistInfoPageOtherArtistLinks.js36
-rw-r--r--src/content/dependencies/generateArtistInfoPageTracksChunkItem.js4
5 files changed, 26 insertions, 21 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
index 44fb42f2..3cda7d90 100644
--- a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
@@ -154,7 +154,7 @@ export default {
 
       itemOtherArtistLinks:
         query.chunks.map(({chunk}) =>
-          chunk.map(({contribs}) => relation('generateArtistInfoPageOtherArtistLinks', contribs, artist))),
+          chunk.map(({contribs}) => relation('generateArtistInfoPageOtherArtistLinks', contribs))),
     };
   },
 
diff --git a/src/content/dependencies/generateArtistInfoPageChunkItem.js b/src/content/dependencies/generateArtistInfoPageChunkItem.js
index b6f40727..ee172f48 100644
--- a/src/content/dependencies/generateArtistInfoPageChunkItem.js
+++ b/src/content/dependencies/generateArtistInfoPageChunkItem.js
@@ -1,3 +1,5 @@
+import {empty} from '#sugar';
+
 export default {
   extraDependencies: ['html', 'language'],
 
@@ -35,7 +37,7 @@ export default {
       const parts = ['artistPage.creditList.entry'];
       const options = {entry: accentedContent};
 
-      if (slots.otherArtistLinks) {
+      if (!empty(slots.otherArtistLinks)) {
         parts.push('withArtists');
         options.artists = language.formatConjunctionList(slots.otherArtistLinks);
       }
diff --git a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
index 133095ea..f4413197 100644
--- a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
@@ -10,7 +10,6 @@ export default {
   contentDependencies: [
     'generateArtistInfoPageChunk',
     'generateArtistInfoPageChunkItem',
-    'generateArtistInfoPageOtherArtistLinks',
     'linkAlbum',
     'linkFlash',
     'linkFlashAct',
diff --git a/src/content/dependencies/generateArtistInfoPageOtherArtistLinks.js b/src/content/dependencies/generateArtistInfoPageOtherArtistLinks.js
index 471ee26c..dcee9c00 100644
--- a/src/content/dependencies/generateArtistInfoPageOtherArtistLinks.js
+++ b/src/content/dependencies/generateArtistInfoPageOtherArtistLinks.js
@@ -1,24 +1,30 @@
-import {empty} from '#sugar';
+import {unique} from '#sugar';
 
 export default {
   contentDependencies: ['linkArtist'],
 
-  relations(relation, contribs, artist) {
-    const otherArtistContribs =
-      contribs.filter(contrib => contrib.artist !== artist);
+  query(contribs) {
+    const associatedContributionsByOtherArtists =
+      contribs
+        .flatMap(ownContrib =>
+          ownContrib.associatedContributions
+            .filter(associatedContrib =>
+              associatedContrib.artist !== ownContrib.artist));
 
-    if (empty(otherArtistContribs)) {
-      return {};
-    }
+    const otherArtists =
+      unique(
+        associatedContributionsByOtherArtists
+          .map(contrib => contrib.artist));
 
-    const otherArtistLinks =
-      otherArtistContribs
-        .map(contrib => relation('linkArtist', contrib.artist));
-
-    return {otherArtistLinks};
+    return {otherArtists};
   },
 
-  generate(relations) {
-    return relations.otherArtistLinks ?? null;
-  },
+  relations: (relation, query) => ({
+    artistLinks:
+      query.otherArtists
+        .map(artist => relation('linkArtist', artist)),
+  }),
+
+  generate: (relations) =>
+    relations.artistLinks,
 };
diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js b/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
index 03ca2ef5..9674eb4f 100644
--- a/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
+++ b/src/content/dependencies/generateArtistInfoPageTracksChunkItem.js
@@ -73,9 +73,7 @@ export default {
       relation('linkTrack', query.track),
 
     otherArtistLinks:
-      relation('generateArtistInfoPageOtherArtistLinks',
-        contribs,
-        artist),
+      relation('generateArtistInfoPageOtherArtistLinks', contribs),
   }),
 
   data: (query) => ({