« 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/composite/wiki-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-12 17:26:40 -0300
commit55df0a77ab929592cce98d36db71315c6c534aa2 (patch)
treed1175659856c72e6e92d517d2337e88c7997473c /src/data/composite/wiki-data
parent72f5aafcbb4de53eadef3cd7603856b37ac9cc49 (diff)
data: apply contribution dates when resolving
Diffstat (limited to 'src/data/composite/wiki-data')
-rw-r--r--src/data/composite/wiki-data/exitWithoutContribs.js1
-rw-r--r--src/data/composite/wiki-data/withResolvedContribs.js20
2 files changed, 18 insertions, 3 deletions
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,
+              })),
         });
       },
     },