From 76e508ffe3818a78fb941ecde05fe9c269e8bc22 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" <qznebula@protonmail.com> Date: Wed, 19 Feb 2025 16:24:14 -0400 Subject: data: isOriginalRelease -> isMainRelease, etc Also isRerelease -> isSecondaryRelease Im sure this is completely bug free and will not involve squashing one million additional commits --- .../composite/things/artist/artistTotalDuration.js | 8 +- src/data/composite/things/track/index.js | 8 +- .../inheritContributionListFromMainRelease.js | 44 +++++++++++ .../inheritContributionListFromOriginalRelease.js | 44 ----------- .../things/track/inheritFromMainRelease.js | 41 +++++++++++ .../things/track/inheritFromOriginalRelease.js | 41 ----------- .../things/track/withAlwaysReferenceByDirectory.js | 27 +++---- src/data/composite/things/track/withMainRelease.js | 70 ++++++++++++++++++ .../composite/things/track/withOriginalRelease.js | 70 ------------------ .../composite/things/track/withOtherReleases.js | 19 ++--- .../things/track/withPropertyFromMainRelease.js | 86 ++++++++++++++++++++++ .../track/withPropertyFromOriginalRelease.js | 86 ---------------------- 12 files changed, 273 insertions(+), 271 deletions(-) create mode 100644 src/data/composite/things/track/inheritContributionListFromMainRelease.js delete mode 100644 src/data/composite/things/track/inheritContributionListFromOriginalRelease.js create mode 100644 src/data/composite/things/track/inheritFromMainRelease.js delete mode 100644 src/data/composite/things/track/inheritFromOriginalRelease.js create mode 100644 src/data/composite/things/track/withMainRelease.js delete mode 100644 src/data/composite/things/track/withOriginalRelease.js create mode 100644 src/data/composite/things/track/withPropertyFromMainRelease.js delete mode 100644 src/data/composite/things/track/withPropertyFromOriginalRelease.js (limited to 'src/data/composite') diff --git a/src/data/composite/things/artist/artistTotalDuration.js b/src/data/composite/things/artist/artistTotalDuration.js index a4a33542..b8a205fe 100644 --- a/src/data/composite/things/artist/artistTotalDuration.js +++ b/src/data/composite/things/artist/artistTotalDuration.js @@ -48,18 +48,18 @@ export default templateCompositeFrom({ withPropertyFromList({ list: '#allContributions.thing', - property: input.value('isOriginalRelease'), + property: input.value('isMainRelease'), }), withFilteredList({ list: '#allContributions', - filter: '#allContributions.thing.isOriginalRelease', + filter: '#allContributions.thing.isMainRelease', }).outputs({ - '#filteredList': '#originalContributions', + '#filteredList': '#mainReleaseContributions', }), withContributionListSums({ - list: '#originalContributions', + list: '#mainReleaseContributions', }), exposeDependency({ diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js index 32c72f78..492b35be 100644 --- a/src/data/composite/things/track/index.js +++ b/src/data/composite/things/track/index.js @@ -1,15 +1,15 @@ export {default as exitWithoutUniqueCoverArt} from './exitWithoutUniqueCoverArt.js'; -export {default as inheritContributionListFromOriginalRelease} from './inheritContributionListFromOriginalRelease.js'; -export {default as inheritFromOriginalRelease} from './inheritFromOriginalRelease.js'; +export {default as inheritContributionListFromMainRelease} from './inheritContributionListFromMainRelease.js'; +export {default as inheritFromMainRelease} from './inheritFromMainRelease.js'; export {default as withAlbum} from './withAlbum.js'; export {default as withAlwaysReferenceByDirectory} from './withAlwaysReferenceByDirectory.js'; export {default as withContainingTrackSection} from './withContainingTrackSection.js'; export {default as withDate} from './withDate.js'; export {default as withDirectorySuffix} from './withDirectorySuffix.js'; export {default as withHasUniqueCoverArt} from './withHasUniqueCoverArt.js'; -export {default as withOriginalRelease} from './withOriginalRelease.js'; +export {default as withMainRelease} from './withMainRelease.js'; export {default as withOtherReleases} from './withOtherReleases.js'; export {default as withPropertyFromAlbum} from './withPropertyFromAlbum.js'; -export {default as withPropertyFromOriginalRelease} from './withPropertyFromOriginalRelease.js'; +export {default as withPropertyFromMainRelease} from './withPropertyFromMainRelease.js'; export {default as withSuffixDirectoryFromAlbum} from './withSuffixDirectoryFromAlbum.js'; export {default as withTrackArtDate} from './withTrackArtDate.js'; diff --git a/src/data/composite/things/track/inheritContributionListFromMainRelease.js b/src/data/composite/things/track/inheritContributionListFromMainRelease.js new file mode 100644 index 00000000..89252feb --- /dev/null +++ b/src/data/composite/things/track/inheritContributionListFromMainRelease.js @@ -0,0 +1,44 @@ +// Like inheritFromMainRelease, but tuned for contributions. +// Recontextualizes contributions for this track. + +import {input, templateCompositeFrom} from '#composite'; + +import {exposeDependency, raiseOutputWithoutDependency} + from '#composite/control-flow'; +import {withRecontextualizedContributionList, withRedatedContributionList} + from '#composite/wiki-data'; + +import withDate from './withDate.js'; +import withPropertyFromMainRelease + from './withPropertyFromMainRelease.js'; + +export default templateCompositeFrom({ + annotation: `inheritContributionListFromMainRelease`, + + steps: () => [ + withPropertyFromMainRelease({ + property: input.thisProperty(), + notFoundValue: input.value([]), + }), + + raiseOutputWithoutDependency({ + dependency: '#isSecondaryRelease', + mode: input.value('falsy'), + }), + + withRecontextualizedContributionList({ + list: '#mainReleaseValue', + }), + + withDate(), + + withRedatedContributionList({ + list: '#mainReleaseValue', + date: '#date', + }), + + exposeDependency({ + dependency: '#mainReleaseValue', + }), + ], +}); diff --git a/src/data/composite/things/track/inheritContributionListFromOriginalRelease.js b/src/data/composite/things/track/inheritContributionListFromOriginalRelease.js deleted file mode 100644 index f4ae3ddb..00000000 --- a/src/data/composite/things/track/inheritContributionListFromOriginalRelease.js +++ /dev/null @@ -1,44 +0,0 @@ -// Like inheritFromOriginalRelease, but tuned for contributions. -// Recontextualized contributions for this track. - -import {input, templateCompositeFrom} from '#composite'; - -import {exposeDependency, raiseOutputWithoutDependency} - from '#composite/control-flow'; -import {withRecontextualizedContributionList, withRedatedContributionList} - from '#composite/wiki-data'; - -import withDate from './withDate.js'; -import withPropertyFromOriginalRelease - from './withPropertyFromOriginalRelease.js'; - -export default templateCompositeFrom({ - annotation: `inheritContributionListFromOriginalRelease`, - - steps: () => [ - withPropertyFromOriginalRelease({ - property: input.thisProperty(), - notFoundValue: input.value([]), - }), - - raiseOutputWithoutDependency({ - dependency: '#isRerelease', - mode: input.value('falsy'), - }), - - withRecontextualizedContributionList({ - list: '#originalValue', - }), - - withDate(), - - withRedatedContributionList({ - list: '#originalValue', - date: '#date', - }), - - exposeDependency({ - dependency: '#originalValue', - }), - ], -}); diff --git a/src/data/composite/things/track/inheritFromMainRelease.js b/src/data/composite/things/track/inheritFromMainRelease.js new file mode 100644 index 00000000..b1cbb65e --- /dev/null +++ b/src/data/composite/things/track/inheritFromMainRelease.js @@ -0,0 +1,41 @@ +// Early exits with the value for the same property as specified on the +// main release, if this track is a secondary release, and otherwise continues +// without providing any further dependencies. +// +// Like withMainRelease, this will early exit (with notFoundValue) if the +// main release is specified by reference and that reference doesn't +// resolve to anything. + +import {input, templateCompositeFrom} from '#composite'; + +import {exposeDependency, raiseOutputWithoutDependency} + from '#composite/control-flow'; + +import withPropertyFromMainRelease + from './withPropertyFromMainRelease.js'; + +export default templateCompositeFrom({ + annotation: `inheritFromMainRelease`, + + inputs: { + notFoundValue: input({ + defaultValue: null, + }), + }, + + steps: () => [ + withPropertyFromMainRelease({ + property: input.thisProperty(), + notFoundValue: input('notFoundValue'), + }), + + raiseOutputWithoutDependency({ + dependency: '#isSecondaryRelease', + mode: input.value('falsy'), + }), + + exposeDependency({ + dependency: '#mainReleaseValue', + }), + ], +}); diff --git a/src/data/composite/things/track/inheritFromOriginalRelease.js b/src/data/composite/things/track/inheritFromOriginalRelease.js deleted file mode 100644 index 38ab06be..00000000 --- a/src/data/composite/things/track/inheritFromOriginalRelease.js +++ /dev/null @@ -1,41 +0,0 @@ -// Early exits with the value for the same property as specified on the -// original release, if this track is a rerelease, and otherwise continues -// without providing any further dependencies. -// -// Like withOriginalRelease, this will early exit (with notFoundValue) if the -// original release is specified by reference and that reference doesn't -// resolve to anything. - -import {input, templateCompositeFrom} from '#composite'; - -import {exposeDependency, raiseOutputWithoutDependency} - from '#composite/control-flow'; - -import withPropertyFromOriginalRelease - from './withPropertyFromOriginalRelease.js'; - -export default templateCompositeFrom({ - annotation: `inheritFromOriginalRelease`, - - inputs: { - notFoundValue: input({ - defaultValue: null, - }), - }, - - steps: () => [ - withPropertyFromOriginalRelease({ - property: input.thisProperty(), - notFoundValue: input('notFoundValue'), - }), - - raiseOutputWithoutDependency({ - dependency: '#isRerelease', - mode: input.value('falsy'), - }), - - exposeDependency({ - dependency: '#originalValue', - }), - ], -}); diff --git a/src/data/composite/things/track/withAlwaysReferenceByDirectory.js b/src/data/composite/things/track/withAlwaysReferenceByDirectory.js index 26c5ba97..aebcf793 100644 --- a/src/data/composite/things/track/withAlwaysReferenceByDirectory.js +++ b/src/data/composite/things/track/withAlwaysReferenceByDirectory.js @@ -51,7 +51,7 @@ export default templateCompositeFrom({ // Remaining code is for defaulting to true if this track is a rerelease of // another with the same name, so everything further depends on access to - // trackData as well as originalReleaseTrack. + // trackData as well as mainReleaseTrack. exitWithoutDependency({ dependency: 'trackData', @@ -60,45 +60,46 @@ export default templateCompositeFrom({ }), exitWithoutDependency({ - dependency: 'originalReleaseTrack', + dependency: 'mainReleaseTrack', value: input.value(false), }), - // It's necessary to use the custom trackOriginalReleasesOnly find function + // It's necessary to use the custom trackMainReleasesOnly find function // here, so as to avoid recursion issues - the find.track() function depends // on accessing each track's alwaysReferenceByDirectory, which means it'll // hit *this track* - and thus this step - and end up recursing infinitely. - // By definition, find.trackOriginalReleasesOnly excludes tracks which have - // an originalReleaseTrack update value set, which means even though it does + // By definition, find.trackMainReleasesOnly excludes tracks which have + // an mainReleaseTrack update value set, which means even though it does // still access each of tracks' `alwaysReferenceByDirectory` property, it // won't access that of *this* track - it will never proceed past the // `exitWithoutDependency` step directly above, so there's no opportunity // for recursion. withResolvedReference({ - ref: 'originalReleaseTrack', + ref: 'mainReleaseTrack', data: 'trackData', - find: input.value(find.trackOriginalReleasesOnly), + find: input.value(find.trackMainReleasesOnly), }).outputs({ - '#resolvedReference': '#originalRelease', + '#resolvedReference': '#mainRelease', }), exitWithoutDependency({ - dependency: '#originalRelease', + dependency: '#mainRelease', value: input.value(false), }), withPropertyFromObject({ - object: '#originalRelease', + object: '#mainRelease', property: input.value('name'), }), { - dependencies: ['name', '#originalRelease.name'], + dependencies: ['name', '#mainRelease.name'], compute: (continuation, { name, - ['#originalRelease.name']: originalName, + ['#mainRelease.name']: mainReleaseName, }) => continuation({ - ['#alwaysReferenceByDirectory']: name === originalName, + ['#alwaysReferenceByDirectory']: + name === mainReleaseName, }), }, ], diff --git a/src/data/composite/things/track/withMainRelease.js b/src/data/composite/things/track/withMainRelease.js new file mode 100644 index 00000000..3a91edae --- /dev/null +++ b/src/data/composite/things/track/withMainRelease.js @@ -0,0 +1,70 @@ +// Just includes the main release of this track as a dependency. +// If this track isn't a secondary release, then it'll provide null, unless +// the {selfIfMain} option is set, in which case it'll provide this track +// itself. This will early exit (with notFoundValue) if the main release +// is specified by reference and that reference doesn't resolve to anything. + +import {input, templateCompositeFrom} from '#composite'; + +import {exitWithoutDependency, withResultOfAvailabilityCheck} + from '#composite/control-flow'; +import {withResolvedReference} from '#composite/wiki-data'; +import {soupyFind} from '#composite/wiki-properties'; + +export default templateCompositeFrom({ + annotation: `withMainRelease`, + + inputs: { + selfIfMain: input({type: 'boolean', defaultValue: false}), + notFoundValue: input({defaultValue: null}), + }, + + outputs: ['#mainRelease'], + + steps: () => [ + withResultOfAvailabilityCheck({ + from: 'mainReleaseTrack', + }), + + { + dependencies: [ + input.myself(), + input('selfIfMain'), + '#availability', + ], + + compute: (continuation, { + [input.myself()]: track, + [input('selfIfMain')]: selfIfMain, + '#availability': availability, + }) => + (availability + ? continuation() + : continuation.raiseOutput({ + ['#mainRelease']: + (selfIfMain ? track : null), + })), + }, + + withResolvedReference({ + ref: 'mainReleaseTrack', + find: soupyFind.input('track'), + }), + + exitWithoutDependency({ + dependency: '#resolvedReference', + value: input('notFoundValue'), + }), + + { + dependencies: ['#resolvedReference'], + + compute: (continuation, { + ['#resolvedReference']: resolvedReference, + }) => + continuation({ + ['#mainRelease']: resolvedReference, + }), + }, + ], +}); diff --git a/src/data/composite/things/track/withOriginalRelease.js b/src/data/composite/things/track/withOriginalRelease.js deleted file mode 100644 index 7aefc64a..00000000 --- a/src/data/composite/things/track/withOriginalRelease.js +++ /dev/null @@ -1,70 +0,0 @@ -// Just includes the original release of this track as a dependency. -// If this track isn't a rerelease, then it'll provide null, unless the -// {selfIfOriginal} option is set, in which case it'll provide this track -// itself. This will early exit (with notFoundValue) if the original release -// is specified by reference and that reference doesn't resolve to anything. - -import {input, templateCompositeFrom} from '#composite'; - -import {exitWithoutDependency, withResultOfAvailabilityCheck} - from '#composite/control-flow'; -import {withResolvedReference} from '#composite/wiki-data'; -import {soupyFind} from '#composite/wiki-properties'; - -export default templateCompositeFrom({ - annotation: `withOriginalRelease`, - - inputs: { - selfIfOriginal: input({type: 'boolean', defaultValue: false}), - notFoundValue: input({defaultValue: null}), - }, - - outputs: ['#originalRelease'], - - steps: () => [ - withResultOfAvailabilityCheck({ - from: 'originalReleaseTrack', - }), - - { - dependencies: [ - input.myself(), - input('selfIfOriginal'), - '#availability', - ], - - compute: (continuation, { - [input.myself()]: track, - [input('selfIfOriginal')]: selfIfOriginal, - '#availability': availability, - }) => - (availability - ? continuation() - : continuation.raiseOutput({ - ['#originalRelease']: - (selfIfOriginal ? track : null), - })), - }, - - withResolvedReference({ - ref: 'originalReleaseTrack', - find: soupyFind.input('track'), - }), - - exitWithoutDependency({ - dependency: '#resolvedReference', - value: input('notFoundValue'), - }), - - { - dependencies: ['#resolvedReference'], - - compute: (continuation, { - ['#resolvedReference']: resolvedReference, - }) => - continuation({ - ['#originalRelease']: resolvedReference, - }), - }, - ], -}); diff --git a/src/data/composite/things/track/withOtherReleases.js b/src/data/composite/things/track/withOtherReleases.js index f8c1c3f0..3fec8742 100644 --- a/src/data/composite/things/track/withOtherReleases.js +++ b/src/data/composite/things/track/withOtherReleases.js @@ -2,7 +2,7 @@ import {input, templateCompositeFrom} from '#composite'; import {exitWithoutDependency} from '#composite/control-flow'; -import withOriginalRelease from './withOriginalRelease.js'; +import withMainRelease from './withMainRelease.js'; export default templateCompositeFrom({ annotation: `withOtherReleases`, @@ -15,26 +15,27 @@ export default templateCompositeFrom({ mode: input.value('empty'), }), - withOriginalRelease({ - selfIfOriginal: input.value(true), + withMainRelease({ + selfIfMain: input.value(true), notFoundValue: input.value([]), }), + // TODO: Jegus shouldn't this be a proper reverse list { - dependencies: [input.myself(), '#originalRelease', 'trackData'], + dependencies: [input.myself(), '#mainRelease', 'trackData'], compute: (continuation, { [input.myself()]: thisTrack, - ['#originalRelease']: originalRelease, + ['#mainRelease']: mainRelease, trackData, }) => continuation({ ['#otherReleases']: - (originalRelease === thisTrack + (mainRelease === thisTrack ? [] - : [originalRelease]) + : [mainRelease]) .concat(trackData.filter(track => - track !== originalRelease && + track !== mainRelease && track !== thisTrack && - track.originalReleaseTrack === originalRelease)), + track.mainReleaseTrack === mainRelease)), }), }, ], diff --git a/src/data/composite/things/track/withPropertyFromMainRelease.js b/src/data/composite/things/track/withPropertyFromMainRelease.js new file mode 100644 index 00000000..393a4c63 --- /dev/null +++ b/src/data/composite/things/track/withPropertyFromMainRelease.js @@ -0,0 +1,86 @@ +// Provides a value inherited from the main release, if applicable, and a +// flag indicating if this track is a secondary release or not. +// +// Like withMainRelease, this will early exit (with notFoundValue) if the +// main release is specified by reference and that reference doesn't +// resolve to anything. + +import {input, templateCompositeFrom} from '#composite'; + +import {withResultOfAvailabilityCheck} from '#composite/control-flow'; +import {withPropertyFromObject} from '#composite/data'; + +import withMainRelease from './withMainRelease.js'; + +export default templateCompositeFrom({ + annotation: `inheritFromMainRelease`, + + inputs: { + property: input({type: 'string'}), + + notFoundValue: input({ + defaultValue: null, + }), + }, + + outputs: ({ + [input.staticValue('property')]: property, + }) => + ['#isSecondaryRelease'].concat( + (property + ? ['#mainRelease.' + property] + : ['#mainReleaseValue'])), + + steps: () => [ + withMainRelease({ + notFoundValue: input('notFoundValue'), + }), + + withResultOfAvailabilityCheck({ + from: '#mainRelease', + }), + + { + dependencies: [ + '#availability', + input.staticValue('property'), + ], + + compute: (continuation, { + ['#availability']: availability, + [input.staticValue('property')]: property, + }) => + (availability + ? continuation() + : continuation.raiseOutput( + Object.assign( + {'#isSecondaryRelease': false}, + (property + ? {['#mainRelease.' + property]: null} + : {'#mainReleaseValue': null})))), + }, + + withPropertyFromObject({ + object: '#mainRelease', + property: input('property'), + }), + + { + dependencies: [ + '#value', + input.staticValue('property'), + ], + + compute: (continuation, { + ['#value']: value, + [input.staticValue('property')]: property, + }) => + continuation.raiseOutput( + Object.assign( + {'#isSecondaryRelease': true}, + (property + ? {['#mainRelease.' + property]: value} + : {'#mainReleaseValue': value}))), + }, + ], +}); diff --git a/src/data/composite/things/track/withPropertyFromOriginalRelease.js b/src/data/composite/things/track/withPropertyFromOriginalRelease.js deleted file mode 100644 index fd37f6de..00000000 --- a/src/data/composite/things/track/withPropertyFromOriginalRelease.js +++ /dev/null @@ -1,86 +0,0 @@ -// Provides a value inherited from the original release, if applicable, and a -// flag indicating if this track is a rerelase or not. -// -// Like withOriginalRelease, this will early exit (with notFoundValue) if the -// original release is specified by reference and that reference doesn't -// resolve to anything. - -import {input, templateCompositeFrom} from '#composite'; - -import {withResultOfAvailabilityCheck} from '#composite/control-flow'; -import {withPropertyFromObject} from '#composite/data'; - -import withOriginalRelease from './withOriginalRelease.js'; - -export default templateCompositeFrom({ - annotation: `inheritFromOriginalRelease`, - - inputs: { - property: input({type: 'string'}), - - notFoundValue: input({ - defaultValue: null, - }), - }, - - outputs: ({ - [input.staticValue('property')]: property, - }) => - ['#isRerelease'].concat( - (property - ? ['#original.' + property] - : ['#originalValue'])), - - steps: () => [ - withOriginalRelease({ - notFoundValue: input('notFoundValue'), - }), - - withResultOfAvailabilityCheck({ - from: '#originalRelease', - }), - - { - dependencies: [ - '#availability', - input.staticValue('property'), - ], - - compute: (continuation, { - ['#availability']: availability, - [input.staticValue('property')]: property, - }) => - (availability - ? continuation() - : continuation.raiseOutput( - Object.assign( - {'#isRerelease': false}, - (property - ? {['#original.' + property]: null} - : {'#originalValue': null})))), - }, - - withPropertyFromObject({ - object: '#originalRelease', - property: input('property'), - }), - - { - dependencies: [ - '#value', - input.staticValue('property'), - ], - - compute: (continuation, { - ['#value']: value, - [input.staticValue('property')]: property, - }) => - continuation.raiseOutput( - Object.assign( - {'#isRerelease': true}, - (property - ? {['#original.' + property]: value} - : {'#originalValue': value}))), - }, - ], -}); -- cgit 1.3.0-6-gf8a5