From cf7e1def135f925fefcde55e130c76598ab69cd4 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 10 Apr 2024 19:57:12 -0300 Subject: content: gAIPChunk: consolidate date processing --- .../generateArtistInfoPageTracksChunk.js | 36 +++++----------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'src/content/dependencies/generateArtistInfoPageTracksChunk.js') diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunk.js b/src/content/dependencies/generateArtistInfoPageTracksChunk.js index cc9b898f..b42e4165 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunk.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunk.js @@ -1,4 +1,4 @@ -import {empty, unique} from '#sugar'; +import {unique} from '#sugar'; import {getTotalDuration} from '#wiki-data'; export default { @@ -27,34 +27,17 @@ export default { data(_artist, album, trackContribLists) { const data = {}; - const allDates = - trackContribLists - .flat() - .filter(contrib => contrib.date) - .map(contrib => contrib.date); - - if (!empty(allDates)) { - const earliestDate = - allDates - .reduce((a, b) => a <= b ? a : b); - - const latestDate = - allDates - .reduce((a, b) => a <= b ? b : a); + const contribs = + trackContribLists.flat(); - if (+earliestDate === +latestDate) { - data.date = earliestDate; - } else { - data.earliestDate = earliestDate; - data.latestDate = latestDate; - } - } + data.dates = + contribs + .map(contrib => contrib.date); // TODO: Duration stuff should *maybe* be in proper data logic? Maaaybe? const durationTerms = unique( - trackContribLists - .flat() + contribs .filter(contrib => contrib.countInDurationTotals) .map(contrib => contrib.thing) .filter(track => track.isOriginalRelease) @@ -75,10 +58,7 @@ export default { albumLink: relations.albumLink, - date: data.date ?? null, - dateRangeStart: data.earliestDate ?? null, - dateRangeEnd: data.latestDate ?? null, - + dates: data.dates, duration: data.duration, durationApproximate: data.durationApproximate, -- cgit 1.3.0-6-gf8a5