diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/data/composite/things/track/index.js | 1 | ||||
| -rw-r--r-- | src/data/composite/things/track/withAllReleases.js | 57 | ||||
| -rw-r--r-- | src/data/composite/things/track/withOtherReleases.js | 8 | ||||
| -rw-r--r-- | src/data/things/track.js | 39 |
4 files changed, 38 insertions, 67 deletions
diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js index 61807018..17e4aeff 100644 --- a/src/data/composite/things/track/index.js +++ b/src/data/composite/things/track/index.js @@ -2,7 +2,6 @@ export {default as alwaysReferenceByDirectory} from './alwaysReferenceByDirector export {default as exitWithoutUniqueCoverArt} from './exitWithoutUniqueCoverArt.js'; export {default as inheritContributionListFromMainRelease} from './inheritContributionListFromMainRelease.js'; export {default as inheritFromMainRelease} from './inheritFromMainRelease.js'; -export {default as withAllReleases} from './withAllReleases.js'; export {default as withDirectorySuffix} from './withDirectorySuffix.js'; export {default as withOtherReleases} from './withOtherReleases.js'; export {default as withPropertyFromAlbum} from './withPropertyFromAlbum.js'; diff --git a/src/data/composite/things/track/withAllReleases.js b/src/data/composite/things/track/withAllReleases.js deleted file mode 100644 index 078209a9..00000000 --- a/src/data/composite/things/track/withAllReleases.js +++ /dev/null @@ -1,57 +0,0 @@ -// Gets all releases of the current track. All items of the outputs are -// distinct Track objects; one track is the main release; all else are -// secondary releases of that main release; and one item, which may be -// the main release or one of the secondary releases, is the current -// track. The results are sorted by date, and it is possible that the -// main release is not actually the earliest/first. - -import {input, templateCompositeFrom} from '#composite'; -import {sortByDate} from '#sort'; - -import {withPropertyFromObject} from '#composite/data'; - -export default templateCompositeFrom({ - annotation: `withAllReleases`, - - outputs: ['#allReleases'], - - steps: () => [ - { - dependencies: [ - 'mainReleaseTrack', - 'secondaryReleases', - input.myself(), - ], - - compute: (continuation, { - mainReleaseTrack, - secondaryReleases, - [input.myself()]: thisTrack, - }) => - (mainReleaseTrack - ? continuation({ - ['#mainReleaseTrack']: mainReleaseTrack, - ['#secondaryReleaseTracks']: mainReleaseTrack.secondaryReleases, - }) - : continuation({ - ['#mainReleaseTrack']: thisTrack, - ['#secondaryReleaseTracks']: secondaryReleases, - })), - }, - - { - dependencies: [ - '#mainReleaseTrack', - '#secondaryReleaseTracks', - ], - - compute: (continuation, { - ['#mainReleaseTrack']: mainReleaseTrack, - ['#secondaryReleaseTracks']: secondaryReleaseTracks, - }) => continuation({ - ['#allReleases']: - sortByDate([mainReleaseTrack, ...secondaryReleaseTracks]), - }), - }, - ], -}); diff --git a/src/data/composite/things/track/withOtherReleases.js b/src/data/composite/things/track/withOtherReleases.js index bb3e8983..ccf57deb 100644 --- a/src/data/composite/things/track/withOtherReleases.js +++ b/src/data/composite/things/track/withOtherReleases.js @@ -3,21 +3,17 @@ import {input, templateCompositeFrom} from '#composite'; -import withAllReleases from './withAllReleases.js'; - export default templateCompositeFrom({ annotation: `withOtherReleases`, outputs: ['#otherReleases'], steps: () => [ - withAllReleases(), - { - dependencies: [input.myself(), '#allReleases'], + dependencies: [input.myself(), 'allReleases'], compute: (continuation, { [input.myself()]: thisTrack, - ['#allReleases']: allReleases, + ['allReleases']: allReleases, }) => continuation({ ['#otherReleases']: allReleases.filter(track => track !== thisTrack), diff --git a/src/data/things/track.js b/src/data/things/track.js index e957a73f..a8c4f8d9 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -4,6 +4,7 @@ import CacheableObject from '#cacheable-object'; import {colors} from '#cli'; import {input} from '#composite'; import {onlyItem} from '#sugar'; +import {sortByDate} from '#sort'; import Thing from '#thing'; import {getKebabCase} from '#wiki-data'; @@ -88,7 +89,6 @@ import { exitWithoutUniqueCoverArt, inheritContributionListFromMainRelease, inheritFromMainRelease, - withAllReleases, withDirectorySuffix, withOtherReleases, withPropertyFromAlbum, @@ -953,8 +953,41 @@ export class Track extends Thing { }), allReleases: [ - withAllReleases(), - exposeDependency({dependency: '#allReleases'}), + { + dependencies: [ + 'mainReleaseTrack', + 'secondaryReleases', + input.myself(), + ], + + compute: (continuation, { + mainReleaseTrack, + secondaryReleases, + [input.myself()]: thisTrack, + }) => + (mainReleaseTrack + ? continuation({ + ['#mainReleaseTrack']: mainReleaseTrack, + ['#secondaryReleaseTracks']: mainReleaseTrack.secondaryReleases, + }) + : continuation({ + ['#mainReleaseTrack']: thisTrack, + ['#secondaryReleaseTracks']: secondaryReleases, + })), + }, + + { + dependencies: [ + '#mainReleaseTrack', + '#secondaryReleaseTracks', + ], + + compute: ({ + ['#mainReleaseTrack']: mainReleaseTrack, + ['#secondaryReleaseTracks']: secondaryReleaseTracks, + }) => + sortByDate([mainReleaseTrack, ...secondaryReleaseTracks]), + }, ], otherReleases: [ |