From 5db0e13f3a70612b453124c0d00a4933c4d24b88 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 6 Mar 2024 14:28:35 -0400 Subject: data: Artist.totalDuration This is sort of a stub / proof of concept function. The contained logic may be refactored a bit more still! --- .../composite/things/artist/artistTotalDuration.js | 72 ++++++++++++++++++++++ src/data/composite/things/artist/index.js | 1 + 2 files changed, 73 insertions(+) create mode 100644 src/data/composite/things/artist/artistTotalDuration.js create mode 100644 src/data/composite/things/artist/index.js (limited to 'src/data/composite') 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'; -- cgit 1.3.0-6-gf8a5