« get me outta code hell

support & enable Sampled Tracks - 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>2022-11-27 02:00:30 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-11-27 02:00:30 -0400
commit903e21d8afa9b3262194f641f8bee0955289bf21 (patch)
tree7e12050d9baa1992ed9532ac40b93f6b4f890f98 /src/data
parent398e8c25073a88cbf7e9861445c87dc9e995978a (diff)
support & enable Sampled Tracks
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things.js23
-rw-r--r--src/data/yaml.js4
2 files changed, 25 insertions, 2 deletions
diff --git a/src/data/things.js b/src/data/things.js
index ee458006..2037faca 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -718,6 +718,7 @@ Track.propertyDescriptors = {
   coverArtistContribsByRef: Thing.common.contribsByRef(),
 
   referencedTracksByRef: Thing.common.referenceList(Track),
+  sampledTracksByRef: Thing.common.referenceList(Track),
   artTagsByRef: Thing.common.referenceList(ArtTag),
 
   hasCoverArt: {
@@ -914,6 +915,12 @@ Track.propertyDescriptors = {
     find.track
   ),
 
+  sampledTracks: Thing.common.dynamicThingsFromReferenceList(
+    'sampledTracksByRef',
+    'trackData',
+    find.track
+  ),
+
   // Specifically exclude re-releases from this list - while it's useful to
   // get from a re-release to the tracks it references, re-releases aren't
   // generally relevant from the perspective of the tracks being referenced.
@@ -937,6 +944,22 @@ Track.propertyDescriptors = {
     },
   },
 
+  // For the same reasoning, exclude re-releases from sampled tracks too.
+  sampledByTracks: {
+    flags: {expose: true},
+
+    expose: {
+      dependencies: ['trackData'],
+
+      compute: ({trackData, [Track.instance]: track}) =>
+        trackData
+          ? trackData
+              .filter((t) => !t.originalReleaseTrack)
+              .filter((t) => t.sampledTracks?.includes(track))
+          : [],
+    },
+  },
+
   // Previously known as: (track).flashes
   featuredInFlashes: Thing.common.reverseReferenceList(
     'flashData',
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 2adce50b..6ba19c06 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -278,6 +278,7 @@ export const processTrackDocument = makeProcessDocument(Track, {
     hasURLs: 'Has URLs',
 
     referencedTracksByRef: 'Referenced Tracks',
+    sampledTracksByRef: 'Sampled Tracks',
     artistContribsByRef: 'Artists',
     contributorContribsByRef: 'Contributors',
     coverArtistContribsByRef: 'Cover Artists',
@@ -289,8 +290,6 @@ export const processTrackDocument = makeProcessDocument(Track, {
 
     additionalFiles: 'Additional Files',
   },
-
-  ignoredFields: ['Sampled Tracks'],
 });
 
 export const processArtistDocument = makeProcessDocument(Artist, {
@@ -1264,6 +1263,7 @@ export function filterReferenceErrors(wikiData) {
       contributorContribsByRef: '_contrib',
       coverArtistContribsByRef: '_contrib',
       referencedTracksByRef: 'track',
+      sampledTracksByRef: 'track',
       artTagsByRef: 'artTag',
       originalReleaseTrackByRef: 'track',
     }],