« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/things')
-rw-r--r--src/data/composite/things/track/index.js1
-rw-r--r--src/data/composite/things/track/withMainRelease.js137
-rw-r--r--src/data/composite/things/track/withMainReleaseTrack.js14
3 files changed, 5 insertions, 147 deletions
diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js
index 1a696b1b..20bc3ff2 100644
--- a/src/data/composite/things/track/index.js
+++ b/src/data/composite/things/track/index.js
@@ -4,7 +4,6 @@ export {default as inheritContributionListFromMainRelease} from './inheritContri
 export {default as inheritFromMainRelease} from './inheritFromMainRelease.js';
 export {default as withAllReleases} from './withAllReleases.js';
 export {default as withDirectorySuffix} from './withDirectorySuffix.js';
-export {default as withMainRelease} from './withMainRelease.js';
 export {default as withMainReleaseTrack} from './withMainReleaseTrack.js';
 export {default as withOtherReleases} from './withOtherReleases.js';
 export {default as withPropertyFromAlbum} from './withPropertyFromAlbum.js';
diff --git a/src/data/composite/things/track/withMainRelease.js b/src/data/composite/things/track/withMainRelease.js
deleted file mode 100644
index fb1342ec..00000000
--- a/src/data/composite/things/track/withMainRelease.js
+++ /dev/null
@@ -1,137 +0,0 @@
-// Resolves this track's `mainRelease` reference, using weird-ass atypical
-// machinery that operates on soupyFind and does not operate on findMixed,
-// let alone a prim and proper standalone find spec.
-//
-// Raises null only if there is no `mainRelease` reference provided at all.
-// This will early exit (with notFoundValue) if the reference doesn't resolve.
-//
-
-import {input, templateCompositeFrom} from '#composite';
-
-import {raiseOutputWithoutDependency} from '#composite/control-flow';
-import {withPropertyFromObject} from '#composite/data';
-import {withResolvedReference} from '#composite/wiki-data';
-import {soupyFind} from '#composite/wiki-properties';
-
-export default templateCompositeFrom({
-  annotation: `withMainRelease`,
-
-  inputs: {
-    from: input({
-      defaultDependency: '_mainRelease',
-      acceptsNull: true,
-    }),
-
-    notFoundValue: input({defaultValue: null}),
-  },
-
-  outputs: ['#mainRelease'],
-
-  steps: () => [
-    raiseOutputWithoutDependency({
-      dependency: input('from'),
-      output: input.value({'#mainRelease': null}),
-    }),
-
-    {
-      dependencies: [input('from'), 'name'],
-      compute: (continuation, {
-        [input('from')]: ref,
-        ['name']: ownName,
-      }) =>
-        (ref === 'same name single'
-          ? continuation({
-              ['#albumOrTrackReference']: null,
-              ['#sameNameSingleReference']: ownName,
-            })
-          : continuation({
-              ['#albumOrTrackReference']: ref,
-              ['#sameNameSingleReference']: null,
-            })),
-    },
-
-    withResolvedReference({
-      ref: '#albumOrTrackReference',
-      find: soupyFind.input('trackMainReleasesOnly'),
-    }).outputs({
-      '#resolvedReference': '#matchingTrack',
-    }),
-
-    withResolvedReference({
-      ref: '#albumOrTrackReference',
-      find: soupyFind.input('album'),
-    }).outputs({
-      '#resolvedReference': '#matchingAlbum',
-    }),
-
-    withResolvedReference({
-      ref: '#sameNameSingleReference',
-      find: soupyFind.input('albumSinglesOnly'),
-      findOptions: input.value({
-        fuzz: {
-          capitalization: true,
-          kebab: true,
-        },
-      }),
-    }).outputs({
-      '#resolvedReference': '#sameNameSingle',
-    }),
-
-    {
-      dependencies: ['#sameNameSingle'],
-      compute: (continuation, {
-        ['#sameNameSingle']: sameNameSingle,
-      }) =>
-        (sameNameSingle
-          ? continuation.raiseOutput({
-              ['#mainRelease']:
-                sameNameSingle,
-            })
-          : continuation()),
-    },
-
-    {
-      dependencies: [
-        '#matchingTrack',
-        '#matchingAlbum',
-        input('notFoundValue'),
-      ],
-
-      compute: (continuation, {
-        ['#matchingTrack']: matchingTrack,
-        ['#matchingAlbum']: matchingAlbum,
-        [input('notFoundValue')]: notFoundValue,
-      }) =>
-        (matchingTrack && matchingAlbum
-          ? continuation()
-       : matchingTrack ?? matchingAlbum
-          ? continuation.raiseOutput({
-              ['#mainRelease']:
-                matchingTrack ?? matchingAlbum,
-            })
-          : continuation.exit(notFoundValue)),
-    },
-
-    withPropertyFromObject({
-      object: '#matchingAlbum',
-      property: input.value('tracks'),
-    }),
-
-    {
-      dependencies: [
-        '#matchingAlbum.tracks',
-        '#matchingTrack',
-        input('notFoundValue'),
-      ],
-
-      compute: (continuation, {
-        ['#matchingAlbum.tracks']: matchingAlbumTracks,
-        ['#matchingTrack']: matchingTrack,
-        [input('notFoundValue')]: notFoundValue,
-      }) =>
-        (matchingAlbumTracks.includes(matchingTrack)
-          ? continuation.raiseOutput({'#mainRelease': matchingTrack})
-          : continuation.exit(notFoundValue)),
-    },
-  ],
-});
diff --git a/src/data/composite/things/track/withMainReleaseTrack.js b/src/data/composite/things/track/withMainReleaseTrack.js
index 70d55dd4..c92c2246 100644
--- a/src/data/composite/things/track/withMainReleaseTrack.js
+++ b/src/data/composite/things/track/withMainReleaseTrack.js
@@ -21,8 +21,6 @@ import {
   withPropertyFromObject,
 } from '#composite/data';
 
-import withMainRelease from './withMainRelease.js';
-
 export default templateCompositeFrom({
   annotation: `withMainReleaseTrack`,
 
@@ -58,23 +56,21 @@ export default templateCompositeFrom({
             })),
     },
 
-    withMainRelease(),
-
     exitWithoutDependency({
-      dependency: '#mainRelease',
+      dependency: 'mainRelease',
       value: input('notFoundValue'),
     }),
 
     withPropertyFromObject({
-      object: '#mainRelease',
+      object: 'mainRelease',
       property: input.value('isTrack'),
     }),
 
     {
-      dependencies: ['#mainRelease', '#mainRelease.isTrack'],
+      dependencies: ['mainRelease', '#mainRelease.isTrack'],
 
       compute: (continuation, {
-        ['#mainRelease']: mainRelease,
+        ['mainRelease']: mainRelease,
         ['#mainRelease.isTrack']: mainReleaseIsTrack,
       }) =>
         (mainReleaseIsTrack
@@ -113,7 +109,7 @@ export default templateCompositeFrom({
     },
 
     withPropertyFromObject({
-      object: '#mainRelease',
+      object: 'mainRelease',
       property: input.value('tracks'),
     }),