From caba536171879628837ce2647283526295d4b564 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 22 May 2022 13:17:53 -0300 Subject: exclude re-releases from referencedByTracks prop --- src/data/things.js | 25 ++++++++++++++++++++++--- src/page/track.js | 13 ++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/data/things.js b/src/data/things.js index 18efac47..b4737510 100644 --- a/src/data/things.js +++ b/src/data/things.js @@ -294,7 +294,7 @@ Thing.common = { expose: { dependencies: [singleReferenceProperty, thingDataProperty], compute: ({ [singleReferenceProperty]: ref, [thingDataProperty]: thingData }) => ( - (ref && thingData ? findFn(ref, thingData, {mode: 'quiet'}) : []) + (ref && thingData ? findFn(ref, thingData, {mode: 'quiet'}) : null) ) } }), @@ -854,8 +854,27 @@ Track.propertyDescriptors = { // Previously known as: (track).references referencedTracks: Thing.common.dynamicThingsFromReferenceList('referencedTracksByRef', 'trackData', find.track), - // Previously known as: (track).referencedBy - referencedByTracks: Thing.common.reverseReferenceList('trackData', 'referencedTracks'), + // Specifically exclude re-releases from this list - while it's useful to + // get from a re-release to the tracks it references, re-releases aren't + // generally relevant from the perspective of the tracks being referenced. + // Filtering them from data here hides them from the corresponding field + // on the site (obviously), and has the bonus of not counting them when + // counting the number of times a track has been referenced, for use in + // the "Tracks - by Times Referenced" listing page (or other data + // processing). + referencedByTracks: { + flags: {expose: true}, + + expose: { + dependencies: ['trackData'], + + compute: ({ trackData, [Track.instance]: track }) => (trackData + ? (trackData + .filter(t => !t.originalReleaseTrack) + .filter(t => t.referencedTracks?.includes(track))) + : []) + } + }, // Previously known as: (track).flashes featuredInFlashes: Thing.common.reverseReferenceList('flashData', 'featuredTracks'), diff --git a/src/page/track.js b/src/page/track.js index 22e6c9da..d51cee21 100644 --- a/src/page/track.js +++ b/src/page/track.js @@ -40,17 +40,13 @@ export function write(track, {wikiData}) { .flatMap(track => track.featuredInFlashes.map(flash => ({flash, as: track})))); } - const unbound_getTrackItem = (track, {getArtistString, link, language}) => { - const line = language.$('trackList.item.withArtists', { + const unbound_getTrackItem = (track, {getArtistString, link, language}) => ( + html.tag('li', language.$('trackList.item.withArtists', { track: link.track(track), by: `${language.$('trackList.item.withArtists.by', { artists: getArtistString(track.artistContribs) })}` - }); - return (track.aka - ? `
  • ${language.$('trackList.item.rerelease', {track: line})}
  • ` - : `
  • ${line}
  • `); - }; + }))); const unbound_generateTrackList = (tracks, {getArtistString, link, language}) => html.tag('ul', tracks.map(track => unbound_getTrackItem(track, {getArtistString, link, language})) @@ -156,7 +152,6 @@ export function write(track, {wikiData}) { to, urls, }) => { - const generateTrackList = bindOpts(unbound_generateTrackList, {getArtistString, link, language}); const getTrackItem = bindOpts(unbound_getTrackItem, {getArtistString, link, language}); const cover = getTrackCover(track); @@ -254,7 +249,7 @@ export function write(track, {wikiData}) { `} ${referencedTracks.length && fixWS`

    ${language.$('releaseInfo.tracksReferenced', {track: `${track.name}`})}

    - ${generateTrackList(referencedTracks)} + ${html.tag('ul', referencedTracks.map(getTrackItem))} `} ${referencedByTracks.length && fixWS`

    ${language.$('releaseInfo.tracksThatReference', {track: `${track.name}`})}

    -- cgit 1.3.0-6-gf8a5