« get me outta code hell

data: general withReverse{*}List logic tidying - 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-01-11 13:30:05 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-11 13:30:05 -0400
commit5b16090a206db99a266fcc006921782b37f8d1a0 (patch)
treebf25b80945537886bf5f4ce7d54acb2f94015cc7 /src/data
parent8c35533c5865077ab73657a2104f08709ba6c4e0 (diff)
data: general withReverse{*}List logic tidying
Diffstat (limited to 'src/data')
-rw-r--r--src/data/composite/wiki-data/withReverseContributionList.js9
-rw-r--r--src/data/composite/wiki-data/withReverseReferenceList.js14
-rw-r--r--src/data/composite/wiki-data/withReverseSingleReferenceList.js32
3 files changed, 30 insertions, 25 deletions
diff --git a/src/data/composite/wiki-data/withReverseContributionList.js b/src/data/composite/wiki-data/withReverseContributionList.js
index 2396c3b4..04dc52d7 100644
--- a/src/data/composite/wiki-data/withReverseContributionList.js
+++ b/src/data/composite/wiki-data/withReverseContributionList.js
@@ -27,9 +27,14 @@ export default withReverseList_template({
       '#flattenedList': '#referencingThings',
     }),
 
-    withMappedList({
+    withPropertyFromList({
       list: '#referencingThings',
-      map: input.value(contrib => [contrib.artist]),
+      property: input.value('artist'),
+    }),
+
+    withMappedList({
+      list: '#referencingThings.artist',
+      map: input.value(artist => [artist]),
     }).outputs({
       '#mappedList': '#referencedThings',
     }),
diff --git a/src/data/composite/wiki-data/withReverseReferenceList.js b/src/data/composite/wiki-data/withReverseReferenceList.js
index 41d2ff20..c62408cf 100644
--- a/src/data/composite/wiki-data/withReverseReferenceList.js
+++ b/src/data/composite/wiki-data/withReverseReferenceList.js
@@ -14,13 +14,6 @@ export default withReverseList_template({
   outputName: '#reverseReferenceList',
 
   customCompositionSteps: () => [
-    withPropertyFromList({
-      list: input('data'),
-      property: input('list'),
-    }).outputs({
-      '#values': '#referencedThings',
-    }),
-
     {
       dependencies: [input('data')],
       compute: (continuation, {
@@ -30,5 +23,12 @@ export default withReverseList_template({
           data,
       }),
     },
+
+    withPropertyFromList({
+      list: '#referencingThings',
+      property: input('list'),
+    }).outputs({
+      '#values': '#referencedThings',
+    }),
   ],
 });
diff --git a/src/data/composite/wiki-data/withReverseSingleReferenceList.js b/src/data/composite/wiki-data/withReverseSingleReferenceList.js
index dd97dc66..569e9ba0 100644
--- a/src/data/composite/wiki-data/withReverseSingleReferenceList.js
+++ b/src/data/composite/wiki-data/withReverseSingleReferenceList.js
@@ -6,7 +6,8 @@ import withReverseList_template from './helpers/withReverseList-template.js';
 
 import {input} from '#composite';
 
-import {withMappedList} from '#composite/data';
+import {withAvailabilityFilter} from '#composite/control-flow';
+import {withMappedList, withPropertyFromList} from '#composite/data';
 
 export default withReverseList_template({
   annotation: `withReverseSingleReferenceList`,
@@ -25,24 +26,23 @@ export default withReverseList_template({
       }),
     },
 
+    withPropertyFromList({
+      list: '#referencingThings',
+      property: input('ref'),
+    }).outputs({
+      '#values': '#individualReferencedThings',
+    }),
+
+    withAvailabilityFilter({
+      from: '#individualReferencedThings',
+    }),
+
     // This map wraps each referenced thing in a single-item array.
     // Each referencing thing references exactly one thing, if any.
-    {
-      dependencies: [input('ref')],
-      compute: (continuation, {
-        [input('ref')]: ref,
-      }) => continuation({
-        ['#singleReferenceMap']:
-          thing =>
-            (thing[ref]
-              ? [thing[ref]]
-              : []),
-      }),
-    },
-
     withMappedList({
-      list: '#referencingThings',
-      map: '#singleReferenceMap',
+      list: '#individualReferencedThings',
+      filter: '#availabilityFilter',
+      map: input.value(thing => [thing]),
     }).outputs({
       '#mappedList': '#referencedThings',
     }),