« get me outta code hell

data: ArtTag: chop withAllDescendantArtTags, withAncestorArtTagBaobabTree - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-11-26 19:22:23 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-11-26 20:20:19 -0400
commit40f1bcee514e0c134c92493f14f8b1ddb0d928ca (patch)
tree54e8db6c169625cea63e427cffcba8c98ce57466
parent8835c9c03c837b2f8567730f94b5a85aa7ffdf2c (diff)
data: ArtTag: chop withAllDescendantArtTags, withAncestorArtTagBaobabTree
-rw-r--r--package.json1
-rw-r--r--src/data/composite/things/art-tag/index.js2
-rw-r--r--src/data/composite/things/art-tag/withAllDescendantArtTags.js44
-rw-r--r--src/data/composite/things/art-tag/withAncestorArtTagBaobabTree.js46
-rw-r--r--src/data/things/art-tag.js41
5 files changed, 30 insertions, 104 deletions
diff --git a/package.json b/package.json
index 23874fd8..1e5e241b 100644
--- a/package.json
+++ b/package.json
@@ -20,7 +20,6 @@
         "#composite/data": "./src/data/composite/data/index.js",
         "#composite/wiki-data": "./src/data/composite/wiki-data/index.js",
         "#composite/wiki-properties": "./src/data/composite/wiki-properties/index.js",
-        "#composite/things/art-tag": "./src/data/composite/things/art-tag/index.js",
         "#composite/things/artist": "./src/data/composite/things/artist/index.js",
         "#composite/things/artwork": "./src/data/composite/things/artwork/index.js",
         "#composite/things/content": "./src/data/composite/things/content/index.js",
diff --git a/src/data/composite/things/art-tag/index.js b/src/data/composite/things/art-tag/index.js
deleted file mode 100644
index bbd38293..00000000
--- a/src/data/composite/things/art-tag/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-export {default as withAllDescendantArtTags} from './withAllDescendantArtTags.js';
-export {default as withAncestorArtTagBaobabTree} from './withAncestorArtTagBaobabTree.js';
diff --git a/src/data/composite/things/art-tag/withAllDescendantArtTags.js b/src/data/composite/things/art-tag/withAllDescendantArtTags.js
deleted file mode 100644
index 934999a3..00000000
--- a/src/data/composite/things/art-tag/withAllDescendantArtTags.js
+++ /dev/null
@@ -1,44 +0,0 @@
-// Gets all the art tags which descend from this one - that means its own direct
-// descendants, but also all the direct and indirect desceands of each of those!
-// The results aren't specially sorted, but they won't contain any duplicates
-// (for example if two descendant tags both route deeper to end up including
-// some of the same tags).
-
-import {input, templateCompositeFrom} from '#composite';
-import {unique} from '#sugar';
-
-import {raiseOutputWithoutDependency} from '#composite/control-flow';
-import {withResolvedReferenceList} from '#composite/wiki-data';
-import {soupyFind} from '#composite/wiki-properties';
-
-export default templateCompositeFrom({
-  annotation: `withAllDescendantArtTags`,
-
-  outputs: ['#allDescendantArtTags'],
-
-  steps: () => [
-    raiseOutputWithoutDependency({
-      dependency: '_directDescendantArtTags',
-      mode: input.value('empty'),
-      output: input.value({'#allDescendantArtTags': []})
-    }),
-
-    withResolvedReferenceList({
-      list: '_directDescendantArtTags',
-      find: soupyFind.input('artTag'),
-    }),
-
-    {
-      dependencies: ['#resolvedReferenceList'],
-      compute: (continuation, {
-        ['#resolvedReferenceList']: directDescendantArtTags,
-      }) => continuation({
-        ['#allDescendantArtTags']:
-          unique([
-            ...directDescendantArtTags,
-            ...directDescendantArtTags.flatMap(artTag => artTag.allDescendantArtTags),
-          ]),
-      }),
-    },
-  ],
-})
diff --git a/src/data/composite/things/art-tag/withAncestorArtTagBaobabTree.js b/src/data/composite/things/art-tag/withAncestorArtTagBaobabTree.js
deleted file mode 100644
index e084a42b..00000000
--- a/src/data/composite/things/art-tag/withAncestorArtTagBaobabTree.js
+++ /dev/null
@@ -1,46 +0,0 @@
-// Gets all the art tags which are ancestors of this one as a "baobab tree" -
-// what you'd typically think of as roots are all up in the air! Since this
-// really is backwards from the way that the art tag tree is written in data,
-// chances are pretty good that there will be many of the exact same "leaf"
-// nodes - art tags which don't themselves have any ancestors. In the actual
-// data structure, each node is a Map, with keys for each ancestor and values
-// for each ancestor's own baobab (thus a branching structure, just like normal
-// trees in this regard).
-
-import {input, templateCompositeFrom} from '#composite';
-
-import {raiseOutputWithoutDependency} from '#composite/control-flow';
-import {withReverseReferenceList} from '#composite/wiki-data';
-import {soupyReverse} from '#composite/wiki-properties';
-
-export default templateCompositeFrom({
-  annotation: `withAncestorArtTagBaobabTree`,
-
-  outputs: ['#ancestorArtTagBaobabTree'],
-
-  steps: () => [
-    withReverseReferenceList({
-      reverse: soupyReverse.input('artTagsWhichDirectlyAncestor'),
-    }).outputs({
-      ['#reverseReferenceList']: '#directAncestorArtTags',
-    }),
-
-    raiseOutputWithoutDependency({
-      dependency: '#directAncestorArtTags',
-      mode: input.value('empty'),
-      output: input.value({'#ancestorArtTagBaobabTree': new Map()}),
-    }),
-
-    {
-      dependencies: ['#directAncestorArtTags'],
-      compute: (continuation, {
-        ['#directAncestorArtTags']: directAncestorArtTags,
-      }) => continuation({
-        ['#ancestorArtTagBaobabTree']:
-          new Map(
-            directAncestorArtTags
-              .map(artTag => [artTag, artTag.ancestorArtTagBaobabTree])),
-      }),
-    },
-  ],
-});
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js
index 3570b2e7..1cce5c20 100644
--- a/src/data/things/art-tag.js
+++ b/src/data/things/art-tag.js
@@ -34,9 +34,6 @@ import {
   urls,
 } from '#composite/wiki-properties';
 
-import {withAllDescendantArtTags, withAncestorArtTagBaobabTree}
-  from '#composite/things/art-tag';
-
 export class ArtTag extends Thing {
   static [Thing.referenceType] = 'tag';
   static [Thing.friendlyName] = `Art Tag`;
@@ -113,29 +110,51 @@ export class ArtTag extends Thing {
     }),
 
     indirectlyFeaturedInArtworks: [
-      withAllDescendantArtTags(),
-
       {
-        dependencies: ['#allDescendantArtTags'],
-        compute: ({'#allDescendantArtTags': allDescendantArtTags}) =>
+        dependencies: ['allDescendantArtTags'],
+        compute: ({allDescendantArtTags}) =>
           unique(
             allDescendantArtTags
               .flatMap(artTag => artTag.directlyFeaturedInArtworks)),
       },
     ],
 
+    // All the art tags which descend from this one - that means its own direct
+    // descendants, plus all the direct and indirect descendants of each of those!
+    // The results aren't specially sorted, but they won't contain any duplicates
+    // (for example if two descendant tags both route deeper to end up including
+    // some of the same tags).
     allDescendantArtTags: [
-      withAllDescendantArtTags(),
-      exposeDependency({dependency: '#allDescendantArtTags'}),
+      {
+        dependencies: ['directDescendantArtTags'],
+        compute: ({directDescendantArtTags}) =>
+          unique([
+            ...directDescendantArtTags,
+            ...directDescendantArtTags.flatMap(artTag => artTag.allDescendantArtTags),
+          ]),
+      },
     ],
 
     directAncestorArtTags: reverseReferenceList({
       reverse: soupyReverse.input('artTagsWhichDirectlyAncestor'),
     }),
 
+    // All the art tags which are ancestors of this one as a "baobab tree" -
+    // what you'd typically think of as roots are all up in the air! Since this
+    // really is backwards from the way that the art tag tree is written in data,
+    // chances are pretty good that there will be many of the exact same "leaf"
+    // nodes - art tags which don't themselves have any ancestors. In the actual
+    // data structure, each node is a Map, with keys for each ancestor and values
+    // for each ancestor's own baobab (thus a branching structure, just like normal
+    // trees in this regard).
     ancestorArtTagBaobabTree: [
-      withAncestorArtTagBaobabTree(),
-      exposeDependency({dependency: '#ancestorArtTagBaobabTree'}),
+      {
+        dependencies: ['directAncestorArtTags'],
+        compute: ({directAncestorArtTags}) =>
+          new Map(
+            directAncestorArtTags
+              .map(artTag => [artTag, artTag.ancestorArtTagBaobabTree])),
+      },
     ],
   });