diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-11-27 01:30:24 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-11-27 01:30:24 -0400 |
commit | 398e8c25073a88cbf7e9861445c87dc9e995978a (patch) | |
tree | bd7567bffa6afb23e242be11cc36bc5fd95c810b /src | |
parent | dd4e642b381f1af8f235a1eff4eb886b12be31ad (diff) |
only count originals for total duration in most places
Diffstat (limited to 'src')
-rw-r--r-- | src/listing-spec.js | 6 | ||||
-rw-r--r-- | src/page/artist.js | 5 | ||||
-rw-r--r-- | src/page/group.js | 2 | ||||
-rw-r--r-- | src/util/wiki-data.js | 8 |
4 files changed, 15 insertions, 6 deletions
diff --git a/src/listing-spec.js b/src/listing-spec.js index 1bdc4db1..f773bf87 100644 --- a/src/listing-spec.js +++ b/src/listing-spec.js @@ -239,7 +239,7 @@ const listingSpec = [ duration: getTotalDuration([ ...(artist.tracksAsArtist ?? []), ...(artist.tracksAsContributor ?? []), - ]), + ], {originalReleasesOnly: true}), })) .filter(({duration}) => duration > 0) .sort((a, b) => b.duration - a.duration), @@ -525,7 +525,9 @@ const listingSpec = [ groupData .map(group => ({ group, - duration: getTotalDuration(group.albums.flatMap(album => album.tracks)), + duration: getTotalDuration( + group.albums.flatMap(album => album.tracks), + {originalReleasesOnly: true}), })) .sort((a, b) => b.duration - a.duration), diff --git a/src/page/artist.js b/src/page/artist.js index 1b5a5060..6dd2ef30 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -87,6 +87,7 @@ export function write(artist, {wikiData}) { date: +track.date, album: track.album, duration: track.duration, + originalReleaseTrack: track.originalReleaseTrack, artists: track.artistContribs.some(({who}) => who === artist) ? track.artistContribs.filter(({who}) => who !== artist) : track.contributorContribs.filter(({who}) => who !== artist), @@ -103,11 +104,11 @@ export function write(artist, {wikiData}) { date, album, chunk, - duration: getTotalDuration(chunk), + duration: getTotalDuration(chunk, {originalReleasesOnly: true}), })); const trackListChunks = chunkTracks(allTracks); - const totalDuration = getTotalDuration(allTracks); + const totalDuration = getTotalDuration(allTracks.filter(t => !t.originalReleaseTrack)); const countGroups = (things) => { const usedGroups = things.flatMap( diff --git a/src/page/group.js b/src/page/group.js index c261565b..b181bcb2 100644 --- a/src/page/group.js +++ b/src/page/group.js @@ -18,7 +18,7 @@ export function write(group, {wikiData}) { const {albums} = group; const tracks = albums.flatMap((album) => album.tracks); - const totalDuration = getTotalDuration(tracks); + const totalDuration = getTotalDuration(tracks, {originalReleasesOnly: true}); const albumLines = group.albums.map((album) => ({ album, diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index f0812a08..c93cb661 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -395,7 +395,13 @@ export function getFlashLink(flash) { return `https://homestuck.com/story/${flash.page}`; } -export function getTotalDuration(tracks) { +export function getTotalDuration(tracks, { + originalReleasesOnly = false, +} = {}) { + if (originalReleasesOnly) { + tracks = tracks.filter(t => !t.originalReleaseTrack); + } + return accumulateSum(tracks, track => track.duration); } |