« get me outta code hell

data: {albums,tracks}AsCommentator -> reverseReferenceList - 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>2024-01-17 15:35:47 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-17 15:35:47 -0400
commit61e675cd51946c5cc2bbdd500df620e0c870bd3d (patch)
tree1e3dbe729acfb8cf4fb6546d33b8a5235c518019 /src/data
parent301ed2a12f4716a85359b6cb50462e415539553f (diff)
data: {albums,tracks}AsCommentator -> reverseReferenceList
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/artist.js31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/data/things/artist.js b/src/data/things/artist.js
index 66a7346b..f7813b97 100644
--- a/src/data/things/artist.js
+++ b/src/data/things/artist.js
@@ -9,6 +9,7 @@ import {
   flag,
   name,
   reverseContributionList,
+  reverseReferenceList,
   singleReference,
   urls,
   wikiData,
@@ -126,17 +127,10 @@ export class Artist extends Thing {
       },
     ],
 
-    tracksAsCommentator: {
-      flags: {expose: true},
-
-      expose: {
-        dependencies: ['this', 'trackData'],
-
-        compute: ({this: artist, trackData}) =>
-          trackData?.filter(({commentatorArtists}) =>
-            commentatorArtists.includes(artist)) ?? [],
-      },
-    },
+    tracksAsCommentator: reverseReferenceList({
+      data: 'trackData',
+      list: input.value('commentatorArtists'),
+    }),
 
     albumsAsAlbumArtist: reverseContributionList({
       data: 'albumData',
@@ -210,17 +204,10 @@ export class Artist extends Thing {
       },
     ],
 
-    albumsAsCommentator: {
-      flags: {expose: true},
-
-      expose: {
-        dependencies: ['this', 'albumData'],
-
-        compute: ({this: artist, albumData}) =>
-          albumData?.filter(({commentatorArtists}) =>
-            commentatorArtists.includes(artist)) ?? [],
-      },
-    },
+    albumsAsCommentator: reverseReferenceList({
+      data: 'albumData',
+      list: input.value('commentatorArtists'),
+    }),
 
     flashesAsContributor: reverseContributionList({
       data: 'flashData',