« get me outta code hell

content: gAIPChunk: consolidate date processing - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateArtistInfoPageTracksChunk.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-04-10 19:57:12 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:05 -0300
commitcf7e1def135f925fefcde55e130c76598ab69cd4 (patch)
treeb316a9141d3d5447fd90f682778404288e826c9d /src/content/dependencies/generateArtistInfoPageTracksChunk.js
parent019e351a9560b09256dfaf99fea9252029df1701 (diff)
content: gAIPChunk: consolidate date processing
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageTracksChunk.js')
-rw-r--r--src/content/dependencies/generateArtistInfoPageTracksChunk.js36
1 files changed, 8 insertions, 28 deletions
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,