diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-03-15 07:26:04 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-03-15 07:26:04 -0300 |
| commit | 6df88c949acdd4a8eabd0bf4013c2cb7e38bbd6b (patch) | |
| tree | bd5a21accb3d52a868d5e1d4f43e387d44a8cb51 /src/content/dependencies/generateArtistInfoPageTracksChunk.js | |
| parent | 97537deba1919fbbd90b1134351787084ee1444e (diff) | |
content: gAIPTracksChunk: rephrase & tighten up secondary releases preview
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageTracksChunk.js')
| -rw-r--r-- | src/content/dependencies/generateArtistInfoPageTracksChunk.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageTracksChunk.js b/src/content/dependencies/generateArtistInfoPageTracksChunk.js index fc5a617e..b3727756 100644 --- a/src/content/dependencies/generateArtistInfoPageTracksChunk.js +++ b/src/content/dependencies/generateArtistInfoPageTracksChunk.js @@ -8,25 +8,35 @@ function countTowardTrackTotals(contribs) { if (!track) return null; + // For secondary releases the goal is to check if the corresponding + // contribution on the main release would be counted toward track totals. + // If any of the artist's contributions on the secondary release don't + // apparently correspond to any on the main release, those will just + // get checked themselves. if (track.isSecondaryRelease) { - const all = + const relevantProperties = + unique(contribs.map(contrib => contrib.thingProperty)); + + const arrays = Object.fromEntries( - unique(contribs.map(contrib => contrib.thingProperty)) - .map(prop => [ - prop, - track.mainReleaseTrack[prop].slice(), - ])); - - contribs = contribs.flatMap(a => { - const array = all[a.thingProperty]; + relevantProperties.map(prop => [ + prop, + track.mainReleaseTrack[prop].slice(), + ])); + + contribs = contribs.map(a => { + const array = arrays[a.thingProperty]; const index = array.findIndex(b => b.artist === a.artist && b.annotation === a.annotation); - if (index === -1) return []; - return array.splice(index, 1); - }).filter(Boolean); + if (index >= 0) { + return array.splice(index, 1).at(0); + } else { + return a; + } + }); } return contribs.some(contrib => |