From 7fbc5b87ed05bce433ed959ca18119b72835ee41 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 30 Jan 2024 10:52:20 -0400 Subject: content, upd8, yaml: adapt to combined artistData --- .../dependencies/listArtistsByCommentaryEntries.js | 5 +++- .../dependencies/listArtistsByContributions.js | 8 +++++-- src/content/dependencies/listArtistsByDuration.js | 16 ++++++++----- src/content/dependencies/listArtistsByGroup.js | 8 +++++-- .../listArtistsByLatestContribution.js | 3 ++- src/content/dependencies/listArtistsByName.js | 3 ++- src/data/yaml.js | 28 ++++++++++++---------- src/page/artist-alias.js | 2 +- src/page/artist.js | 2 +- src/upd8.js | 20 +++++++++------- src/write/common-templates.js | 2 ++ 11 files changed, 60 insertions(+), 37 deletions(-) diff --git a/src/content/dependencies/listArtistsByCommentaryEntries.js b/src/content/dependencies/listArtistsByCommentaryEntries.js index 4db9885..aac3cfd 100644 --- a/src/content/dependencies/listArtistsByCommentaryEntries.js +++ b/src/content/dependencies/listArtistsByCommentaryEntries.js @@ -10,7 +10,10 @@ export default { }, query({artistData}, spec) { - const artists = sortAlphabetically(artistData.slice()); + const artists = + sortAlphabetically( + artistData.filter(artist => !artist.isAlias)); + const counts = artists.map(artist => artist.tracksAsCommentator.length + diff --git a/src/content/dependencies/listArtistsByContributions.js b/src/content/dependencies/listArtistsByContributions.js index 58c51a4..234c7ed 100644 --- a/src/content/dependencies/listArtistsByContributions.js +++ b/src/content/dependencies/listArtistsByContributions.js @@ -25,8 +25,12 @@ export default { }; const queryContributionInfo = (artistsKey, countsKey, fn) => { - const artists = sortAlphabetically(sprawl.artistData.slice()); - const counts = artists.map(artist => fn(artist)); + const artists = + sortAlphabetically( + sprawl.artistData.filter(artist => !artist.isAlias)); + + const counts = + artists.map(artist => fn(artist)); filterByCount(artists, counts); sortByCount(artists, counts, {greatestFirst: true}); diff --git a/src/content/dependencies/listArtistsByDuration.js b/src/content/dependencies/listArtistsByDuration.js index d6a1897..056b126 100644 --- a/src/content/dependencies/listArtistsByDuration.js +++ b/src/content/dependencies/listArtistsByDuration.js @@ -10,12 +10,16 @@ export default { }, query({artistData}, spec) { - const artists = sortAlphabetically(artistData.slice()); - const durations = artists.map(artist => - getTotalDuration([ - ...(artist.tracksAsArtist ?? []), - ...(artist.tracksAsContributor ?? []), - ], {originalReleasesOnly: true})); + const artists = + sortAlphabetically( + artistData.filter(artist => !artist.isAlias)); + + const durations = + artists.map(artist => + getTotalDuration([ + ...(artist.tracksAsArtist ?? []), + ...(artist.tracksAsContributor ?? []), + ], {originalReleasesOnly: true})); filterByCount(artists, durations); sortByCount(artists, durations, {greatestFirst: true}); diff --git a/src/content/dependencies/listArtistsByGroup.js b/src/content/dependencies/listArtistsByGroup.js index 3778b9e..69f910c 100644 --- a/src/content/dependencies/listArtistsByGroup.js +++ b/src/content/dependencies/listArtistsByGroup.js @@ -15,8 +15,12 @@ export default { }, query(sprawl, spec) { - const artists = sortAlphabetically(sprawl.artistData.slice()); - const groups = sprawl.wikiInfo.divideTrackListsByGroups; + const artists = + sortAlphabetically( + sprawl.artistData.filter(artist => !artist.isAlias)); + + const groups = + sprawl.wikiInfo.divideTrackListsByGroups; if (empty(groups)) { return {spec, artists}; diff --git a/src/content/dependencies/listArtistsByLatestContribution.js b/src/content/dependencies/listArtistsByLatestContribution.js index 45f8390..03c5169 100644 --- a/src/content/dependencies/listArtistsByLatestContribution.js +++ b/src/content/dependencies/listArtistsByLatestContribution.js @@ -145,7 +145,8 @@ export default { // const artistsAlphabetically = - sortAlphabetically(sprawl.artistData.slice()); + sortAlphabetically( + sprawl.artistData.filter(artist => !artist.isAlias)); const artists = Array.from(artistLatestContribMap.keys()); diff --git a/src/content/dependencies/listArtistsByName.js b/src/content/dependencies/listArtistsByName.js index 554b458..7704e97 100644 --- a/src/content/dependencies/listArtistsByName.js +++ b/src/content/dependencies/listArtistsByName.js @@ -12,7 +12,8 @@ export default { spec, artists: - sortAlphabetically(sprawl.artistData.slice()), + sortAlphabetically( + sprawl.artistData.filter(artist => !artist.isAlias)), }), relations: (relation, query) => ({ diff --git a/src/data/yaml.js b/src/data/yaml.js index 0f7f06f..795eddf 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -1118,8 +1118,22 @@ export function filterReferenceErrors(wikiData) { return recursive(obj, keys); } - const aggregate = openAggregate({message: `Errors validating between-thing references in data`}); const boundFind = bindFind(wikiData, {mode: 'error'}); + + const artistAliasData = wikiData.artistData.filter(artist => artist.isAlias); + const findArtistOrAlias = artistRef => { + const alias = find.artistIncludingAliases(artistRef, artistAliasData, {mode: 'quiet'}); + if (alias) { + // No need to check if the original exists here. Aliases are automatically + // created from a field on the original, so the original certainly exists. + const original = alias.aliasedArtist; + throw new Error(`Reference ${colors.red(artistRef)} is to an alias, should be ${colors.green(original.name)}`); + } + + return boundFind.artist(artistRef); + }; + + const aggregate = openAggregate({message: `Errors validating between-thing references in data`}); for (const [thingDataProp, propSpec] of referenceSpec) { const thingData = getNestedProp(wikiData, thingDataProp); @@ -1165,18 +1179,6 @@ export function filterReferenceErrors(wikiData) { let findFn; - const findArtistOrAlias = artistRef => { - const alias = find.artist(artistRef, wikiData.artistAliasData, {mode: 'quiet'}); - if (alias) { - // No need to check if the original exists here. Aliases are automatically - // created from a field on the original, so the original certainly exists. - const original = alias.aliasedArtist; - throw new Error(`Reference ${colors.red(artistRef)} is to an alias, should be ${colors.green(original.name)}`); - } - - return boundFind.artist(artistRef); - }; - switch (findFnKey) { case '_artTag': findFn = boundFind.artTag; diff --git a/src/page/artist-alias.js b/src/page/artist-alias.js index d230522..c117779 100644 --- a/src/page/artist-alias.js +++ b/src/page/artist-alias.js @@ -1,7 +1,7 @@ export const description = `redirects for aliased artist names`; export function targets({wikiData}) { - return wikiData.artistAliasData; + return wikiData.artistData.filter(artist => artist.isAlias); } export function pathsForTarget(aliasArtist) { diff --git a/src/page/artist.js b/src/page/artist.js index b9a2f73..c1543fa 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -6,7 +6,7 @@ export const description = `per-artist info & artwork gallery pages`; // NB: See artist-alias.js for artist alias redirect pages. export function targets({wikiData}) { - return wikiData.artistData; + return wikiData.artistData.filter(artist => !artist.isAlias); } export function pathsForTarget(artist) { diff --git a/src/upd8.js b/src/upd8.js index eaf6b43..af3d107 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -952,13 +952,20 @@ async function main() { Object.assign(wikiData, wikiDataResult); { - const logThings = (thingDataProp, label) => - logInfo` - ${wikiData[thingDataProp]?.length ?? colors.red('(Missing!)')} ${colors.normal(colors.dim(label))}`; + const logThings = (prop, label) => { + const array = + (Array.isArray(prop) + ? prop + : wikiData[prop]); + + logInfo` - ${array?.length ?? colors.red('(Missing!)')} ${colors.normal(colors.dim(label))}`; + } + try { logInfo`Loaded data and processed objects:`; logThings('albumData', 'albums'); logThings('trackData', 'tracks'); - logThings('artistData', 'artists'); + logThings(wikiData.artistData.filter(artist => !artist.isAlias), 'artists'); if (wikiData.flashData) { logThings('flashData', 'flashes'); logThings('flashActData', 'flash acts'); @@ -1050,7 +1057,7 @@ async function main() { // Needed for sorting 'date', 'tracks', // Needed for computing page paths - 'commentary', 'coverArtistContribs', + 'aliasedArtist', 'commentary', 'coverArtistContribs', ]), artTagData: new Set([ @@ -1058,11 +1065,6 @@ async function main() { 'isContentWarning', ]), - artistAliasData: new Set([ - // Needed for computing page paths - 'aliasedArtist', - ]), - flashData: new Set([ // Needed for sorting 'act', 'date', diff --git a/src/write/common-templates.js b/src/write/common-templates.js index d897a73..c9824a4 100644 --- a/src/write/common-templates.js +++ b/src/write/common-templates.js @@ -46,10 +46,12 @@ export function generateRandomLinkDataJSON({wikiData}) { artistDirectories: artistData + .filter(artist => !artist.isAlias) .map(artist => artist.directory), artistNumContributions: artistData + .filter(artist => !artist.isAlias) .map(artist => getArtistNumContributions(artist)), }); } -- cgit 1.3.0-6-gf8a5