« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/composite/things/album/index.js1
-rw-r--r--src/data/composite/things/album/withTrackSections.js21
-rw-r--r--src/data/composite/things/album/withTracks.js9
-rw-r--r--src/data/things/album.js19
-rw-r--r--test/unit/data/things/album.js34
-rw-r--r--test/unit/data/things/track.js18
6 files changed, 26 insertions, 76 deletions
diff --git a/src/data/composite/things/album/index.js b/src/data/composite/things/album/index.js
index 0ef91b87..8b5098f0 100644
--- a/src/data/composite/things/album/index.js
+++ b/src/data/composite/things/album/index.js
@@ -1,2 +1 @@
-export {default as withTrackSections} from './withTrackSections.js';
 export {default as withTracks} from './withTracks.js';
diff --git a/src/data/composite/things/album/withTrackSections.js b/src/data/composite/things/album/withTrackSections.js
deleted file mode 100644
index a56bda31..00000000
--- a/src/data/composite/things/album/withTrackSections.js
+++ /dev/null
@@ -1,21 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-
-import find from '#find';
-
-import {withResolvedReferenceList} from '#composite/wiki-data';
-
-export default templateCompositeFrom({
-  annotation: `withTrackSections`,
-
-  outputs: ['#trackSections'],
-
-  steps: () => [
-    withResolvedReferenceList({
-      list: 'trackSections',
-      data: 'ownTrackSectionData',
-      find: input.value(find.unqualifiedTrackSection),
-    }).outputs({
-      ['#resolvedReferenceList']: '#trackSections',
-    }),
-  ],
-});
diff --git a/src/data/composite/things/album/withTracks.js b/src/data/composite/things/album/withTracks.js
index c8d27c4c..348220e7 100644
--- a/src/data/composite/things/album/withTracks.js
+++ b/src/data/composite/things/album/withTracks.js
@@ -3,7 +3,7 @@ import {input, templateCompositeFrom} from '#composite';
 import {withFlattenedList, withPropertyFromList} from '#composite/data';
 import {withResolvedReferenceList} from '#composite/wiki-data';
 
-import withTrackSections from './withTrackSections.js';
+import {raiseOutputWithoutDependency} from '#composite/control-flow';
 
 export default templateCompositeFrom({
   annotation: `withTracks`,
@@ -11,10 +11,13 @@ export default templateCompositeFrom({
   outputs: ['#tracks'],
 
   steps: () => [
-    withTrackSections(),
+    raiseOutputWithoutDependency({
+      dependency: 'trackSections',
+      output: input.value({'#tracks': []}),
+    }),
 
     withPropertyFromList({
-      list: '#trackSections',
+      list: 'trackSections',
       property: input.value('tracks'),
     }),
 
diff --git a/src/data/things/album.js b/src/data/things/album.js
index ee99c814..f1a7df3d 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -44,6 +44,7 @@ import {
   simpleString,
   singleReference,
   thing,
+  thingList,
   urls,
   wikiData,
 } from '#composite/wiki-properties';
@@ -136,10 +137,8 @@ export class Album extends Thing {
     creditSources: commentary(),
     additionalFiles: additionalFiles(),
 
-    trackSections: referenceList({
-      referenceType: input.value('unqualified-track-section'),
-      data: 'ownTrackSectionData',
-      find: input.value(find.unqualifiedTrackSection),
+    trackSections: thingList({
+      class: input.value(TrackSection),
     }),
 
     artistContribs: contributionList({
@@ -223,10 +222,6 @@ export class Album extends Thing {
       class: input.value(Group),
     }),
 
-    ownTrackSectionData: wikiData({
-      class: input.value(TrackSection),
-    }),
-
     wikiInfo: thing({
       class: input.value(WikiInfo),
     }),
@@ -476,13 +471,7 @@ export class Album extends Thing {
 
         albumData.push(album);
 
-        album.trackSections =
-          trackSections
-            .map(trackSection =>
-              `unqualified-track-section:` +
-              trackSection.unqualifiedDirectory);
-
-        album.ownTrackSectionData = trackSections;
+        album.trackSections = trackSections;
       }
 
       return {albumData, trackSectionData, trackData};
diff --git a/test/unit/data/things/album.js b/test/unit/data/things/album.js
index 06265b09..e9c0d700 100644
--- a/test/unit/data/things/album.js
+++ b/test/unit/data/things/album.js
@@ -262,13 +262,6 @@ t.test(`Album.tracks`, t => {
   const section6 = stubTrackSection(album, [], 'section6');
   const sections = [section1, section2, section3, section4, section5, section6];
 
-  const section1_ref = `unqualified-track-section:section1`;
-  const section2_ref = `unqualified-track-section:section2`;
-  const section3_ref = `unqualified-track-section:section3`;
-  const section4_ref = `unqualified-track-section:section4`;
-  const section5_ref = `unqualified-track-section:section5`;
-  const section6_ref = `unqualified-track-section:section6`;
-
   for (const track of tracks) {
     track.albumData = [album];
   }
@@ -283,8 +276,7 @@ t.test(`Album.tracks`, t => {
   section1.tracks = ['track:track1', 'track:track2', 'track:track3'];
   section1.ownTrackData = [track1, track2, track3];
 
-  album.trackSections = [section1_ref];
-  album.ownTrackSectionData = [section1];
+  album.trackSections = [section1];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #2: pulls tracks from one track section`);
@@ -295,8 +287,7 @@ t.test(`Album.tracks`, t => {
   section1.ownTrackData = [track1];
   section2.ownTrackData = [track2, track3];
 
-  album.trackSections = [section1_ref, section2_ref];
-  album.ownTrackSectionData = [section1, section2];
+  album.trackSections = [section1, section2];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #3: pulls tracks from multiple track sections`);
@@ -311,8 +302,7 @@ t.test(`Album.tracks`, t => {
   section3.ownTrackData = [];
   section4.ownTrackData = [track3];
 
-  album.trackSections = [section1_ref, section2_ref, section3_ref, section4_ref];
-  album.ownTrackSectionData = [section1, section2, section3, section4];
+  album.trackSections = [section1, section2, section3, section4];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #4: filters out references without matches`);
@@ -331,8 +321,7 @@ t.test(`Album.tracks`, t => {
   section5.ownTrackData = [];
   section6.ownTrackData = [track3];
 
-  album.trackSections = [section1_ref, section2_ref, section3_ref, section4_ref, section5_ref, section6_ref];
-  album.ownTrackSectionData = [section1, section2, section3, section4, section5, section6];
+  album.trackSections = [section1, section2, section3, section4, section5, section6];
 
   t.same(album.tracks, [track1, track2, track3],
     `Album.tracks #5: skips empty track sections`);
@@ -372,8 +361,7 @@ t.test(`Album.trackSections`, t => {
   section1.ownTrackData = [track1, track2];
   section2.ownTrackData = [track3, track4];
 
-  album.trackSections = [section1_ref, section2_ref];
-  album.ownTrackSectionData = [section1, section2];
+  album.trackSections = [section1, section2];
 
   t.match(album.trackSections, [
     {tracks: [track1, track2]},
@@ -396,8 +384,7 @@ t.test(`Album.trackSections`, t => {
   section1.name = 'First section';
   section2.name = 'Second section';
 
-  album.trackSections = [section1_ref, section2_ref, section3_ref];
-  album.ownTrackSectionData = [section1, section2, section3];
+  album.trackSections = [section1, section2, section3];
 
   t.match(album.trackSections, [
     {name: 'First section', tracks: [track1]},
@@ -411,7 +398,7 @@ t.test(`Album.trackSections`, t => {
 
   // XXX_decacheWikiData
   album.trackSections = [];
-  album.trackSections = [section1_ref, section2_ref, section3_ref];
+  album.trackSections = [section1, section2, section3];
 
   t.match(album.trackSections, [
     {tracks: [track1], color: '#123456'},
@@ -423,7 +410,7 @@ t.test(`Album.trackSections`, t => {
 
   // XXX_decacheWikiData
   album.trackSections = [];
-  album.trackSections = [section1_ref, section2_ref, section3_ref];
+  album.trackSections = [section1, section2, section3];
 
   t.match(album.trackSections, [
     {tracks: [track1], dateOriginallyReleased: null},
@@ -436,7 +423,7 @@ t.test(`Album.trackSections`, t => {
 
   // XXX_decacheWikiData
   album.trackSections = [];
-  album.trackSections = [section1_ref, section2_ref, section3_ref];
+  album.trackSections = [section1, section2, section3];
 
   t.match(album.trackSections, [
     {tracks: [track1], isDefaultTrackSection: true},
@@ -462,8 +449,7 @@ t.test(`Album.trackSections`, t => {
   section4.color = '#556677';
   section5.color = '#778899';
 
-  album.trackSections = [section1_ref, section2_ref, section3_ref, section4_ref, section5_ref];
-  album.ownTrackSectionData = [section1, section2, section3, section4, section5];
+  album.trackSections = [section1, section2, section3, section4, section5];
 
   t.match(album.trackSections, [
     {tracks: [track1, track2], color: '#112233'},
diff --git a/test/unit/data/things/track.js b/test/unit/data/things/track.js
index 74231e20..e27fb449 100644
--- a/test/unit/data/things/track.js
+++ b/test/unit/data/things/track.js
@@ -19,8 +19,7 @@ function stubAlbum(tracks, directory = 'bar') {
   album.directory = directory;
 
   const trackSection = stubTrackSection(album, tracks);
-  album.trackSections = [`unqualified-track-section:${trackSection.unqualifiedDirectory}`];
-  album.ownTrackSectionData = [trackSection];
+  album.trackSections = [trackSection];
 
   return album;
 }
@@ -96,8 +95,6 @@ t.test(`Track.album`, t => {
   const section2 = new TrackSection();
   section1.unqualifiedDirectory = 'section1';
   section2.unqualifiedDirectory = 'section2';
-  const section1_ref = `unqualified-track-section:section1`;
-  const section2_ref = `unqualified-track-section:section2`;
 
   t.equal(track1.album, null,
     `album #1: defaults to null`);
@@ -110,10 +107,8 @@ t.test(`Track.album`, t => {
   section2.ownAlbumData = [album2];
   section1.tracks = ['track:track1'];
   section2.tracks = ['track:track2'];
-  album1.trackSections = [section1_ref];
-  album2.trackSections = [section2_ref];
-  album1.ownTrackSectionData = [section1];
-  album2.ownTrackSectionData = [section2];
+  album1.trackSections = [section1];
+  album2.trackSections = [section2];
 
   t.equal(track1.album, album1,
     `album #2: is album when album's trackSections matches track`);
@@ -132,7 +127,7 @@ t.test(`Track.album`, t => {
 
   // XXX_decacheWikiData
   album1.trackSections = [];
-  album1.trackSections = [section1_ref];
+  album1.trackSections = [section1];
   track1.albumData = [];
   track1.albumData = [album2, album1];
 
@@ -144,7 +139,7 @@ t.test(`Track.album`, t => {
 
   // XXX_decacheWikiData
   album1.trackSections = [];
-  album1.trackSections = [section1_ref];
+  album1.trackSections = [section1];
   track1.albumData = [];
   track1.albumData = [album2, album1];
 
@@ -320,8 +315,7 @@ t.test(`Track.color`, t => {
   album.color = '#abcdef';
   section.color = '#beeeef';
 
-  album.trackSections = [`unqualified-track-section:section`];
-  album.ownTrackSectionData = [section];
+  album.trackSections = [section];
 
   XXX_decacheWikiData();