diff options
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/data/composite/things/artist/artistTotalDuration.js | 72 | ||||
-rw-r--r-- | src/data/composite/things/artist/index.js | 1 | ||||
-rw-r--r-- | src/data/things/artist.js | 5 |
4 files changed, 79 insertions, 0 deletions
diff --git a/package.json b/package.json index 840f7b97..edb8111d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "#composite/wiki-data": "./src/data/composite/wiki-data/index.js", "#composite/wiki-properties": "./src/data/composite/wiki-properties/index.js", "#composite/things/album": "./src/data/composite/things/album/index.js", + "#composite/things/artist": "./src/data/composite/things/artist/index.js", "#composite/things/contribution": "./src/data/composite/things/contribution/index.js", "#composite/things/flash": "./src/data/composite/things/flash/index.js", "#composite/things/flash-act": "./src/data/composite/things/flash-act/index.js", diff --git a/src/data/composite/things/artist/artistTotalDuration.js b/src/data/composite/things/artist/artistTotalDuration.js new file mode 100644 index 00000000..54204918 --- /dev/null +++ b/src/data/composite/things/artist/artistTotalDuration.js @@ -0,0 +1,72 @@ +import {input, templateCompositeFrom} from '#composite'; + +import {exposeDependency} from '#composite/control-flow'; +import {withFilteredList, withPropertyFromList} from '#composite/data'; +import {withContributionListSums, withReverseContributionList} + from '#composite/wiki-data'; + +export default templateCompositeFrom({ + annotation: `artistTotalDuration`, + + compose: false, + + steps: () => [ + withReverseContributionList({ + data: 'trackData', + list: input.value('artistContribs'), + mode: input.value('contributions'), + }).outputs({ + '#reverseContributionList': '#contributionsAsArtist', + }), + + withReverseContributionList({ + data: 'trackData', + list: input.value('contributorContribs'), + mode: input.value('contributions'), + }).outputs({ + '#reverseContributionList': '#contributionsAsContributor', + }), + + { + dependencies: [ + '#contributionsAsArtist', + '#contributionsAsContributor', + ], + + compute: (continuation, { + ['#contributionsAsArtist']: artistContribs, + ['#contributionsAsContributor']: contributorContribs, + }) => continuation({ + ['#allContributions']: [ + ...artistContribs, + ...contributorContribs, + ], + }), + }, + + withPropertyFromList({ + list: '#allContributions', + property: input.value('thing'), + }), + + withPropertyFromList({ + list: '#allContributions.thing', + property: input.value('isOriginalRelease'), + }), + + withFilteredList({ + list: '#allContributions', + filter: '#allContributions.thing.isOriginalRelease', + }).outputs({ + '#filteredList': '#originalContributions', + }), + + withContributionListSums({ + list: '#originalContributions', + }), + + exposeDependency({ + dependency: '#contributionListDuration', + }), + ], +}); diff --git a/src/data/composite/things/artist/index.js b/src/data/composite/things/artist/index.js new file mode 100644 index 00000000..55514c71 --- /dev/null +++ b/src/data/composite/things/artist/index.js @@ -0,0 +1 @@ +export {default as artistTotalDuration} from './artistTotalDuration.js'; diff --git a/src/data/things/artist.js b/src/data/things/artist.js index 841d652f..3e4c8c2c 100644 --- a/src/data/things/artist.js +++ b/src/data/things/artist.js @@ -12,6 +12,7 @@ import Thing from '#thing'; import {isName, validateArrayItems} from '#validators'; import {getKebabCase} from '#wiki-data'; +import {exposeDependency} from '#composite/control-flow'; import {withReverseContributionList} from '#composite/wiki-data'; import { @@ -27,6 +28,8 @@ import { wikiData, } from '#composite/wiki-properties'; +import {artistTotalDuration} from '#composite/things/artist'; + export class Artist extends Thing { static [Thing.referenceType] = 'artist'; static [Thing.wikiDataArray] = 'artistData'; @@ -225,6 +228,8 @@ export class Artist extends Thing { data: 'flashData', list: input.value('commentatorArtists'), }), + + totalDuration: artistTotalDuration(), }); static [Thing.getSerializeDescriptors] = ({ |