« get me outta code hell

data: apply contribution dates when resolving - 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-03-07 12:19:19 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:03 -0300
commit7aea624c3e101c30e02e5ae08679ec243764632f (patch)
treef47195de41b9237ccd6f5270a0d10645bf3273f8 /src/data
parente0d3028aecb85f64f1e9de713d4e66caee0a0515 (diff)
data: apply contribution dates when resolving
Diffstat (limited to 'src/data')
-rw-r--r--src/data/composite/things/track/withHasUniqueCoverArt.js5
-rw-r--r--src/data/composite/wiki-data/exitWithoutContribs.js1
-rw-r--r--src/data/composite/wiki-data/withResolvedContribs.js20
-rw-r--r--src/data/composite/wiki-properties/contributionList.js10
-rw-r--r--src/data/things/album.js44
-rw-r--r--src/data/things/flash.js4
-rw-r--r--src/data/things/track.js13
7 files changed, 85 insertions, 12 deletions
diff --git a/src/data/composite/things/track/withHasUniqueCoverArt.js b/src/data/composite/things/track/withHasUniqueCoverArt.js
index 96078d5f..f7e65f25 100644
--- a/src/data/composite/things/track/withHasUniqueCoverArt.js
+++ b/src/data/composite/things/track/withHasUniqueCoverArt.js
@@ -29,7 +29,10 @@ export default templateCompositeFrom({
           : continuation()),
     },
 
-    withResolvedContribs({from: 'coverArtistContribs'}),
+    withResolvedContribs({
+      from: 'coverArtistContribs',
+      date: input.value(null),
+    }),
 
     {
       dependencies: ['#resolvedContribs'],
diff --git a/src/data/composite/wiki-data/exitWithoutContribs.js b/src/data/composite/wiki-data/exitWithoutContribs.js
index 2c8219fc..cf52950d 100644
--- a/src/data/composite/wiki-data/exitWithoutContribs.js
+++ b/src/data/composite/wiki-data/exitWithoutContribs.js
@@ -24,6 +24,7 @@ export default templateCompositeFrom({
   steps: () => [
     withResolvedContribs({
       from: input('contribs'),
+      date: input.value(null),
     }),
 
     // TODO: Fairly certain exitWithoutDependency would be sufficient here.
diff --git a/src/data/composite/wiki-data/withResolvedContribs.js b/src/data/composite/wiki-data/withResolvedContribs.js
index fd51c81e..23b91691 100644
--- a/src/data/composite/wiki-data/withResolvedContribs.js
+++ b/src/data/composite/wiki-data/withResolvedContribs.js
@@ -8,7 +8,7 @@ import {input, templateCompositeFrom} from '#composite';
 import find from '#find';
 import {filterMultipleArrays, stitchArrays} from '#sugar';
 import thingConstructors from '#things';
-import {is, isContributionList, isStringNonEmpty} from '#validators';
+import {is, isContributionList, isDate, isStringNonEmpty} from '#validators';
 
 import {raiseOutputWithoutDependency} from '#composite/control-flow';
 import {withPropertiesFromList} from '#composite/data';
@@ -22,6 +22,11 @@ export default templateCompositeFrom({
       acceptsNull: true,
     }),
 
+    date: input({
+      validate: isDate,
+      acceptsNull: true,
+    }),
+
     notFoundMode: input({
       validate: is('exit', 'filter', 'null'),
       defaultValue: 'null',
@@ -70,17 +75,26 @@ export default templateCompositeFrom({
     }),
 
     {
-      dependencies: ['#contribs.artist', '#contribs.annotation'],
+      dependencies: [
+        '#contribs.artist',
+        '#contribs.annotation',
+        input('date'),
+      ],
 
       compute(continuation, {
         ['#contribs.artist']: artist,
         ['#contribs.annotation']: annotation,
+        [input('date')]: date,
       }) {
         filterMultipleArrays(artist, annotation, (artist, _annotation) => artist);
 
         return continuation({
           ['#details']:
-            stitchArrays({artist, annotation}),
+            stitchArrays({artist, annotation})
+              .map(details => ({
+                ...details,
+                date: date ?? null,
+              })),
         });
       },
     },
diff --git a/src/data/composite/wiki-properties/contributionList.js b/src/data/composite/wiki-properties/contributionList.js
index 001aed17..a0e6e52b 100644
--- a/src/data/composite/wiki-properties/contributionList.js
+++ b/src/data/composite/wiki-properties/contributionList.js
@@ -15,7 +15,7 @@
 //
 
 import {input, templateCompositeFrom} from '#composite';
-import {isContributionList} from '#validators';
+import {isContributionList, isDate} from '#validators';
 
 import {exposeConstant, exposeDependencyOrContinue} from '#composite/control-flow';
 import {withResolvedContribs} from '#composite/wiki-data';
@@ -25,12 +25,20 @@ export default templateCompositeFrom({
 
   compose: false,
 
+  inputs: {
+    date: input({
+      validate: isDate,
+      acceptsNull: true,
+    }),
+  },
+
   update: {validate: isContributionList},
 
   steps: () => [
     withResolvedContribs({
       from: input.updateValue(),
       thingProperty: input.thisProperty(),
+      date: input('date'),
     }),
 
     exposeDependencyOrContinue({
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 6b37bc96..b0a46af1 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -136,11 +136,45 @@ export class Album extends Thing {
       find: input.value(find.unqualifiedTrackSection),
     }),
 
-    artistContribs: contributionList(),
-    coverArtistContribs: contributionList(),
-    trackCoverArtistContribs: contributionList(),
-    wallpaperArtistContribs: contributionList(),
-    bannerArtistContribs: contributionList(),
+    artistContribs: contributionList({
+      date: 'date',
+    }),
+
+    coverArtistContribs: [
+      withCoverArtDate({
+        fallback: input.value(true),
+      }),
+
+      contributionList({
+        date: '#coverArtDate',
+      }),
+    ],
+
+    trackCoverArtistContribs: contributionList({
+      // May be null, indicating cover art was added for tracks on the date
+      // each track specifies, or else the track's own release date.
+      date: 'trackArtDate',
+    }),
+
+    wallpaperArtistContribs: [
+      withCoverArtDate({
+        fallback: input.value(true),
+      }),
+
+      contributionList({
+        date: '#coverArtDate',
+      }),
+    ],
+
+    bannerArtistContribs: [
+      withCoverArtDate({
+        fallback: input.value(true),
+      }),
+
+      contributionList({
+        date: '#coverArtDate',
+      }),
+    ],
 
     groups: referenceList({
       class: input.value(Group),
diff --git a/src/data/things/flash.js b/src/data/things/flash.js
index 2c0c1417..7d37ed81 100644
--- a/src/data/things/flash.js
+++ b/src/data/things/flash.js
@@ -98,7 +98,9 @@ export class Flash extends Thing {
 
     coverArtDimensions: dimensions(),
 
-    contributorContribs: contributionList(),
+    contributorContribs: contributionList({
+      date: 'date',
+    }),
 
     featuredTracks: referenceList({
       class: input.value(Track),
diff --git a/src/data/things/track.js b/src/data/things/track.js
index 57d2ed20..5410889f 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -194,9 +194,12 @@ export class Track extends Thing {
     artistContribs: [
       inheritContributionListFromOriginalRelease(),
 
+      withDate(),
+
       withResolvedContribs({
         from: input.updateValue({validate: isContributionList}),
         thingProperty: input.thisProperty(),
+        date: '#date',
       }).outputs({
         '#resolvedContribs': '#artistContribs',
       }),
@@ -219,7 +222,10 @@ export class Track extends Thing {
 
     contributorContribs: [
       inheritContributionListFromOriginalRelease(),
-      contributionList(),
+
+      contributionList({
+        date: 'date',
+      }),
     ],
 
     // Cover artists aren't inherited from the original release, since it
@@ -230,9 +236,14 @@ export class Track extends Thing {
         value: input.value([]),
       }),
 
+      withTrackArtDate({
+        fallback: input.value(true),
+      }),
+
       withResolvedContribs({
         from: input.updateValue({validate: isContributionList}),
         thingProperty: input.thisProperty(),
+        date: '#trackArtDate',
       }).outputs({
         '#resolvedContribs': '#coverArtistContribs',
       }),