« get me outta code hell

data: Artist: chop artistTotalDuration - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-11-26 19:41:56 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-11-26 20:20:19 -0400
commit5a3d62e696f251647ebf11607b05405aaf384957 (patch)
tree96c04c07a4ad0bd3ff981d01a6f0c4172fd24ef9 /src/data
parent40f1bcee514e0c134c92493f14f8b1ddb0d928ca (diff)
data: Artist: chop artistTotalDuration
...and depend on resolved reverse reference lists
Diffstat (limited to 'src/data')
-rw-r--r--src/data/composite/things/artist/artistTotalDuration.js69
-rw-r--r--src/data/composite/things/artist/index.js1
-rw-r--r--src/data/things/artist.js107
3 files changed, 48 insertions, 129 deletions
diff --git a/src/data/composite/things/artist/artistTotalDuration.js b/src/data/composite/things/artist/artistTotalDuration.js
deleted file mode 100644
index b8a205fe..00000000
--- a/src/data/composite/things/artist/artistTotalDuration.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-
-import {exposeDependency} from '#composite/control-flow';
-import {withFilteredList, withPropertyFromList} from '#composite/data';
-import {withContributionListSums, withReverseReferenceList}
-  from '#composite/wiki-data';
-import {soupyReverse} from '#composite/wiki-properties';
-
-export default templateCompositeFrom({
-  annotation: `artistTotalDuration`,
-
-  compose: false,
-
-  steps: () => [
-    withReverseReferenceList({
-      reverse: soupyReverse.input('trackArtistContributionsBy'),
-    }).outputs({
-      '#reverseReferenceList': '#contributionsAsArtist',
-    }),
-
-    withReverseReferenceList({
-      reverse: soupyReverse.input('trackContributorContributionsBy'),
-    }).outputs({
-      '#reverseReferenceList': '#contributionsAsContributor',
-    }),
-
-    {
-      dependencies: [
-        '#contributionsAsArtist',
-        '#contributionsAsContributor',
-      ],
-
-      compute: (continuation, {
-        ['#contributionsAsArtist']: artistContribs,
-        ['#contributionsAsContributor']: contributorContribs,
-      }) => continuation({
-        ['#allContributions']: [
-          ...artistContribs,
-          ...contributorContribs,
-        ],
-      }),
-    },
-
-    withPropertyFromList({
-      list: '#allContributions',
-      property: input.value('thing'),
-    }),
-
-    withPropertyFromList({
-      list: '#allContributions.thing',
-      property: input.value('isMainRelease'),
-    }),
-
-    withFilteredList({
-      list: '#allContributions',
-      filter: '#allContributions.thing.isMainRelease',
-    }).outputs({
-      '#filteredList': '#mainReleaseContributions',
-    }),
-
-    withContributionListSums({
-      list: '#mainReleaseContributions',
-    }),
-
-    exposeDependency({
-      dependency: '#contributionListDuration',
-    }),
-  ],
-});
diff --git a/src/data/composite/things/artist/index.js b/src/data/composite/things/artist/index.js
deleted file mode 100644
index 55514c71..00000000
--- a/src/data/composite/things/artist/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export {default as artistTotalDuration} from './artistTotalDuration.js';
diff --git a/src/data/things/artist.js b/src/data/things/artist.js
index 73ca2b65..5e65e37d 100644
--- a/src/data/things/artist.js
+++ b/src/data/things/artist.js
@@ -18,8 +18,10 @@ import {
   sortContributionsChronologically,
 } from '#sort';
 
-import {exitWithoutDependency, exposeConstant} from '#composite/control-flow';
-import {withReverseReferenceList} from '#composite/wiki-data';
+import {exitWithoutDependency, exposeConstant, exposeDependency}
+  from '#composite/control-flow';
+import {withFilteredList, withPropertyFromList} from '#composite/data';
+import {withContributionListSums} from '#composite/wiki-data';
 
 import {
   constitutibleArtwork,
@@ -37,8 +39,6 @@ import {
   urls,
 } from '#composite/wiki-properties';
 
-import {artistTotalDuration} from '#composite/things/artist';
-
 export class Artist extends Thing {
   static [Thing.referenceType] = 'artist';
   static [Thing.wikiData] = 'artistData';
@@ -146,31 +146,19 @@ export class Artist extends Thing {
     }),
 
     musicContributions: [
-      withReverseReferenceList({
-        reverse: soupyReverse.input('trackArtistContributionsBy'),
-      }).outputs({
-        '#reverseReferenceList': '#trackArtistContribs',
-      }),
-
-      withReverseReferenceList({
-        reverse: soupyReverse.input('trackContributorContributionsBy'),
-      }).outputs({
-        '#reverseReferenceList': '#trackContributorContribs',
-      }),
-
       {
         dependencies: [
-          '#trackArtistContribs',
-          '#trackContributorContribs',
+          'trackArtistContributions',
+          'trackContributorContributions',
         ],
 
         compute: (continuation, {
-          ['#trackArtistContribs']: trackArtistContribs,
-          ['#trackContributorContribs']: trackContributorContribs,
+          trackArtistContributions,
+          trackContributorContributions,
         }) => continuation({
           ['#contributions']: [
-            ...trackArtistContribs,
-            ...trackContributorContribs,
+            ...trackArtistContributions,
+            ...trackContributorContributions,
           ],
         }),
       },
@@ -185,49 +173,25 @@ export class Artist extends Thing {
     ],
 
     artworkContributions: [
-      withReverseReferenceList({
-        reverse: soupyReverse.input('trackCoverArtistContributionsBy'),
-      }).outputs({
-        '#reverseReferenceList': '#trackCoverArtistContribs',
-      }),
-
-      withReverseReferenceList({
-        reverse: soupyReverse.input('albumCoverArtistContributionsBy'),
-      }).outputs({
-        '#reverseReferenceList': '#albumCoverArtistContribs',
-      }),
-
-      withReverseReferenceList({
-        reverse: soupyReverse.input('albumWallpaperArtistContributionsBy'),
-      }).outputs({
-        '#reverseReferenceList': '#albumWallpaperArtistContribs',
-      }),
-
-      withReverseReferenceList({
-        reverse: soupyReverse.input('albumBannerArtistContributionsBy'),
-      }).outputs({
-        '#reverseReferenceList': '#albumBannerArtistContribs',
-      }),
-
       {
         dependencies: [
-          '#trackCoverArtistContribs',
-          '#albumCoverArtistContribs',
-          '#albumWallpaperArtistContribs',
-          '#albumBannerArtistContribs',
+          'trackCoverArtistContributions',
+          'albumCoverArtistContributions',
+          'albumWallpaperArtistContributions',
+          'albumBannerArtistContributions',
         ],
 
         compute: (continuation, {
-          ['#trackCoverArtistContribs']: trackCoverArtistContribs,
-          ['#albumCoverArtistContribs']: albumCoverArtistContribs,
-          ['#albumWallpaperArtistContribs']: albumWallpaperArtistContribs,
-          ['#albumBannerArtistContribs']: albumBannerArtistContribs,
+          trackCoverArtistContributions,
+          albumCoverArtistContributions,
+          albumWallpaperArtistContributions,
+          albumBannerArtistContributions,
         }) => continuation({
           ['#contributions']: [
-            ...trackCoverArtistContribs,
-            ...albumCoverArtistContribs,
-            ...albumWallpaperArtistContribs,
-            ...albumBannerArtistContribs,
+            ...trackCoverArtistContributions,
+            ...albumCoverArtistContributions,
+            ...albumWallpaperArtistContributions,
+            ...albumBannerArtistContributions,
           ],
         }),
       },
@@ -241,7 +205,32 @@ export class Artist extends Thing {
       },
     ],
 
-    totalDuration: artistTotalDuration(),
+    totalDuration: [
+      withPropertyFromList({
+        list: 'musicContributions',
+        property: input.value('thing'),
+      }),
+
+      withPropertyFromList({
+        list: '#musicContributions.thing',
+        property: input.value('isMainRelease'),
+      }),
+
+      withFilteredList({
+        list: 'musicContributions',
+        filter: '#musicContributions.thing.isMainRelease',
+      }).outputs({
+        '#filteredList': '#mainReleaseContributions',
+      }),
+
+      withContributionListSums({
+        list: '#mainReleaseContributions',
+      }),
+
+      exposeDependency({
+        dependency: '#contributionListDuration',
+      }),
+    ],
   });
 
   static [Thing.getSerializeDescriptors] = ({