From 9e7807a8500a0208f8f8cbded89dfb06f1e21061 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 3 Oct 2025 15:07:42 -0300 Subject: data: "Main Release: same name single" --- src/data/checks.js | 11 ++++++ src/data/composite/things/track/withMainRelease.js | 41 ++++++++++++++++++++-- src/data/things/album.js | 18 ++++++++-- 3 files changed, 66 insertions(+), 4 deletions(-) (limited to 'src/data') diff --git a/src/data/checks.js b/src/data/checks.js index 5688b979..b7a237ad 100644 --- a/src/data/checks.js +++ b/src/data/checks.js @@ -350,6 +350,17 @@ export function filterReferenceErrors(wikiData, { findFn = ref => { // Mocking what's going on in `withMainRelease`. + if (ref === 'same name single') { + // Accessing the current thing here. + try { + return boundFind.albumSinglesOnly(thing.name); + } catch (caughtError) { + throw new Error( + `Didn't match a single with the same name`, + {cause: caughtError}); + } + } + let track, trackError; let album, albumError; diff --git a/src/data/composite/things/track/withMainRelease.js b/src/data/composite/things/track/withMainRelease.js index b1f427eb..f1b0841a 100644 --- a/src/data/composite/things/track/withMainRelease.js +++ b/src/data/composite/things/track/withMainRelease.js @@ -33,20 +33,57 @@ export default templateCompositeFrom({ output: input.value({'#mainRelease': null}), }), + { + dependencies: [input('from'), 'name'], + compute: (continuation, { + [input('from')]: ref, + ['name']: ownName, + }) => + (ref === 'same name single' + ? continuation({ + ['#albumOrTrackReference']: null, + ['#sameNameSingleReference']: ownName, + }) + : continuation({ + ['#albumOrTrackReference']: ref, + ['#sameNameSingleReference']: null, + })), + }, + withResolvedReference({ - ref: input('from'), + ref: '#albumOrTrackReference', find: soupyFind.input('trackMainReleasesOnly'), }).outputs({ '#resolvedReference': '#matchingTrack', }), withResolvedReference({ - ref: input('from'), + ref: '#albumOrTrackReference', find: soupyFind.input('album'), }).outputs({ '#resolvedReference': '#matchingAlbum', }), + withResolvedReference({ + ref: '#sameNameSingleReference', + find: soupyFind.input('albumSinglesOnly'), + }).outputs({ + '#resolvedReference': '#sameNameSingle', + }), + + { + dependencies: ['#sameNameSingle'], + compute: (continuation, { + ['#sameNameSingle']: sameNameSingle, + }) => + (sameNameSingle + ? continuation.raiseOutput({ + ['#mainRelease']: + sameNameSingle, + }) + : continuation()), + }, + { dependencies: [ '#matchingTrack', diff --git a/src/data/things/album.js b/src/data/things/album.js index ac947cfa..2817d78d 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -510,6 +510,20 @@ export class Album extends Thing { : [album.name]), }, + albumSinglesOnly: { + referencing: ['album'], + + bindTo: 'albumData', + + incldue: album => + album.style === 'single', + + getMatchableNames: album => + (album.alwaysReferenceByDirectory + ? [] + : [album.name]), + }, + albumWithArtwork: { referenceTypes: [ 'album', @@ -523,8 +537,8 @@ export class Album extends Thing { album.hasCoverArt, getMatchableNames: album => - (album.alwaysReferenceByDirectory - ? [] + (album.alwaysReferenceByDirectory + ? [] : [album.name]), }, -- cgit 1.3.0-6-gf8a5