« get me outta code hell

content, data: Divide Flash Lists By Sides - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-03-25 11:18:42 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-03-25 11:18:42 -0300
commit3e5c8f731117b01fdf46c4fe066e1c349dee3827 (patch)
tree503cc42fdb167c2542b8c5b6ec50a06aa112e5bc /src/data
parent263f32444d5158582520615d9d8520bc562e6918 (diff)
content, data: Divide Flash Lists By Sides
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/Track.js39
-rw-r--r--src/data/things/WikiInfo.js30
2 files changed, 65 insertions, 4 deletions
diff --git a/src/data/things/Track.js b/src/data/things/Track.js
index 5cb6388a..36e3733d 100644
--- a/src/data/things/Track.js
+++ b/src/data/things/Track.js
@@ -5,7 +5,7 @@ import {colors} from '#cli';
 import {input, V} from '#composite';
 import find, {keyRefRegex} from '#find';
 import {onlyItem} from '#sugar';
-import {sortByDate} from '#sort';
+import {sortByDate, sortFlashesChronologically} from '#sort';
 import Thing from '#thing';
 import {compareKebabCase} from '#wiki-data';
 
@@ -884,9 +884,44 @@ export class Track extends Thing {
       reverse: soupyReverse.input('tracksWhichSample'),
     }),
 
-    featuredInFlashes: reverseReferenceList({
+    ownFeaturedInFlashes: reverseReferenceList({
       reverse: soupyReverse.input('flashesWhichFeature'),
     }),
+
+    featuredInFlashes: [
+      {
+        dependencies: ['allReleases'],
+        compute: (continuation, {allReleases}) => continuation({
+          ['#data']:
+            allReleases.flatMap(track =>
+              track.ownFeaturedInFlashes.map(flash => ({
+                flash,
+                track,
+
+                // These properties are used for the upcoming sort.
+                act: flash.act,
+                date: flash.date,
+              }))),
+        }),
+      },
+
+      {
+        dependencies: ['#data'],
+        compute: (continuation, {'#data': data}) => continuation({
+          ['#sortedData']:
+            sortFlashesChronologically(data),
+        }),
+      },
+
+      {
+        dependencies: ['#sortedData'],
+        compute: ({'#sortedData': sortedData}) =>
+          sortedData.map(item => ({
+            flash: item.flash,
+            as: item.track,
+          })),
+      },
+    ],
   });
 
   static [Thing.yamlDocumentSpec] = {
diff --git a/src/data/things/WikiInfo.js b/src/data/things/WikiInfo.js
index ffb18cd8..364ae517 100644
--- a/src/data/things/WikiInfo.js
+++ b/src/data/things/WikiInfo.js
@@ -1,6 +1,5 @@
 import {input, V} from '#composite';
 import Thing from '#thing';
-import {parseContributionPresets, parseWallpaperParts} from '#yaml';
 
 import {
   isBoolean,
@@ -10,9 +9,16 @@ import {
   isNumber,
 } from '#validators';
 
+import {
+  parseAnnotatedReferences,
+  parseContributionPresets,
+  parseWallpaperParts,
+} from '#yaml';
+
 import {exitWithoutDependency, exposeConstant} from '#composite/control-flow';
 
 import {
+  annotatedReferenceList,
   canonicalBase,
   color,
   contentString,
@@ -30,7 +36,7 @@ export class WikiInfo extends Thing {
   static [Thing.wikiData] = 'wikiInfo';
   static [Thing.oneInstancePerWiki] = true;
 
-  static [Thing.getPropertyDescriptors] = ({Group}) => ({
+  static [Thing.getPropertyDescriptors] = ({FlashSide, Group}) => ({
     // Update & expose
 
     name: name(V('Unnamed Wiki')),
@@ -75,6 +81,15 @@ export class WikiInfo extends Thing {
       find: soupyFind.input('group'),
     }),
 
+    divideFlashListsBySides: annotatedReferenceList({
+      class: input.value(FlashSide),
+      find: soupyFind.input('flashSide'),
+
+      reference: input.value('side'),
+      annotation: input.value('label'),
+      thing: input.value('side'),
+    }),
+
     contributionPresets: {
       flags: {update: true, expose: true},
       update: {validate: isContributionPresetList},
@@ -147,6 +162,17 @@ export class WikiInfo extends Thing {
 
       'Divide Track Lists By Groups': {property: 'divideTrackListsByGroups'},
 
+      'Divide Flash Lists By Sides': {
+        property: 'divideFlashListsBySides',
+        transform: value =>
+          parseAnnotatedReferences(value, {
+            referenceField: 'Side',
+            referenceProperty: 'side',
+            annotationField: 'Label',
+            annotationProperty: 'label',
+          }),
+      },
+
       'Contribution Presets': {
         property: 'contributionPresets',
         transform: parseContributionPresets,