diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-02 10:55:38 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 22:56:06 -0300 |
commit | 4aa153ebae1360e390b9d372fabf457ee8b21705 (patch) | |
tree | a1cff366b439550227fa6ef7b9b4f6c575e51daf /src | |
parent | 5550f8ec487c3cae87de36f4e0c1fe9d6df8e36c (diff) |
content, page, util: general contributions usage cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateAlbumInfoPage.js | 11 | ||||
-rw-r--r-- | src/content/dependencies/generateArtistGalleryPage.js | 10 | ||||
-rw-r--r-- | src/content/dependencies/generateArtistInfoPage.js | 29 | ||||
-rw-r--r-- | src/content/dependencies/generateArtistNavLinks.js | 4 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackChronologyLinks.js | 25 | ||||
-rw-r--r-- | src/content/dependencies/listArtistsByContributions.js | 36 | ||||
-rw-r--r-- | src/content/dependencies/listArtistsByGroup.js | 27 | ||||
-rw-r--r-- | src/page/artist.js | 4 | ||||
-rw-r--r-- | src/util/wiki-data.js | 21 |
9 files changed, 116 insertions, 51 deletions
diff --git a/src/content/dependencies/generateAlbumInfoPage.js b/src/content/dependencies/generateAlbumInfoPage.js index d4ea52de..02854a16 100644 --- a/src/content/dependencies/generateAlbumInfoPage.js +++ b/src/content/dependencies/generateAlbumInfoPage.js @@ -56,10 +56,13 @@ export default { getThings(artist) { const getDate = thing => thing.coverArtDate ?? thing.date; - const things = [ - ...artist.albumsAsCoverArtist, - ...artist.tracksAsCoverArtist, - ].filter(getDate); + const things = + ([ + artist.albumCoverArtistContributions, + artist.trackCoverArtistContributions, + ]).flat() + .map(({thing}) => thing) + .filter(getDate); return sortAlbumsTracksChronologically(things, {getDate}); }, diff --git a/src/content/dependencies/generateArtistGalleryPage.js b/src/content/dependencies/generateArtistGalleryPage.js index db8f123f..26a894c6 100644 --- a/src/content/dependencies/generateArtistGalleryPage.js +++ b/src/content/dependencies/generateArtistGalleryPage.js @@ -14,10 +14,12 @@ export default { extraDependencies: ['html', 'language'], query(artist) { - const things = [ - ...artist.albumsAsCoverArtist, - ...artist.tracksAsCoverArtist, - ]; + const things = + ([ + artist.albumCoverArtistContributions, + artist.trackCoverArtistContributions, + ]).flat() + .map(({thing}) => thing); sortAlbumsTracksChronologically(things, { latestFirst: true, diff --git a/src/content/dependencies/generateArtistInfoPage.js b/src/content/dependencies/generateArtistInfoPage.js index d1941b91..88e501ce 100644 --- a/src/content/dependencies/generateArtistInfoPage.js +++ b/src/content/dependencies/generateArtistInfoPage.js @@ -31,25 +31,32 @@ export default { return { // Even if an artist has served as both "artist" (compositional) and // "contributor" (instruments, production, etc) on the same track, that - // track only counts as one unique contribution. + // track only counts as one unique contribution in the list. allTracks: - unique([...artist.tracksAsArtist, ...artist.tracksAsContributor]), + unique( + ([ + artist.trackArtistContributions, + artist.trackContributorContributions, + ]).flat() + .map(({thing}) => thing)), // Artworks are different, though. We intentionally duplicate album data // objects when the artist has contributed some combination of cover art, // wallpaper, and banner - these each count as a unique contribution. - allArtworks: [ - ...artist.albumsAsCoverArtist, - ...artist.albumsAsWallpaperArtist, - ...artist.albumsAsBannerArtist, - ...artist.tracksAsCoverArtist, - ], + allArtworks: + ([ + artist.albumCoverArtistContributions, + artist.albumWallpaperArtistContributions, + artist.albumBannerArtistContributions, + artist.trackCoverArtistContributions, + ]).flat() + .map(({thing}) => thing), // Banners and wallpapers don't show up in the artist gallery page, only // cover art. hasGallery: - !empty(artist.albumsAsCoverArtist) || - !empty(artist.tracksAsCoverArtist), + !empty(artist.albumCoverArtistContributions) || + !empty(artist.trackCoverArtistContributions), }; }, @@ -100,7 +107,7 @@ export default { } } - if (sprawl.enableFlashesAndGames && !empty(artist.flashesAsContributor)) { + if (sprawl.enableFlashesAndGames && !empty(artist.flashContributorContributions)) { const flashes = sections.flashes = {}; flashes.heading = relation('generateContentHeading'); flashes.list = relation('generateArtistInfoPageFlashesChunkedList', artist); diff --git a/src/content/dependencies/generateArtistNavLinks.js b/src/content/dependencies/generateArtistNavLinks.js index aa95dba2..527e4741 100644 --- a/src/content/dependencies/generateArtistNavLinks.js +++ b/src/content/dependencies/generateArtistNavLinks.js @@ -24,8 +24,8 @@ export default { relation('linkArtist', artist); if ( - !empty(artist.albumsAsCoverArtist) || - !empty(artist.tracksAsCoverArtist) + !empty(artist.albumCoverArtistContributions) || + !empty(artist.trackCoverArtistContributions) ) { relations.artistGalleryLink = relation('linkArtistGallery', artist); diff --git a/src/content/dependencies/generateTrackChronologyLinks.js b/src/content/dependencies/generateTrackChronologyLinks.js index 5f6b0771..f9ad6299 100644 --- a/src/content/dependencies/generateTrackChronologyLinks.js +++ b/src/content/dependencies/generateTrackChronologyLinks.js @@ -38,9 +38,11 @@ export default { const things = ([ - ...artist.tracksAsArtist, - ...artist.tracksAsContributor, - ]).filter(getDate) + artist.trackArtistContributions, + artist.trackContributorContributions, + ]).flat() + .map(({thing}) => thing) + .filter(getDate) .filter(albumFilter); return sortAlbumsTracksChronologically(things, {getDate}); @@ -61,11 +63,20 @@ export default { getThings(artist) { const getDate = thing => thing.coverArtDate ?? thing.date; + // Album artwork isn't part of cover artist chronology scoped to + // even the same album - we use this list to show "nth track art". + const applicableContributions = + (album + ? artist.trackCoverArtistContributions + : ([ + artist.albumCoverArtistContributions, + artist.trackCoverArtistContributions, + ]).flat()); + const things = - ([ - ...artist.albumsAsCoverArtist, - ...artist.tracksAsCoverArtist, - ]).filter(getDate) + applicableContributions + .map(({thing}) => thing) + .filter(getDate) .filter(albumFilter); return sortAlbumsTracksChronologically(things, {getDate}); diff --git a/src/content/dependencies/listArtistsByContributions.js b/src/content/dependencies/listArtistsByContributions.js index 0af586cd..41944959 100644 --- a/src/content/dependencies/listArtistsByContributions.js +++ b/src/content/dependencies/listArtistsByContributions.js @@ -1,6 +1,13 @@ import {sortAlphabetically, sortByCount} from '#sort'; -import {empty, filterByCount, filterMultipleArrays, stitchArrays, unique} - from '#sugar'; + +import { + accumulateSum, + empty, + filterByCount, + filterMultipleArrays, + stitchArrays, + unique, +} from '#sugar'; export default { contentDependencies: ['generateListingPage', 'linkArtist'], @@ -38,26 +45,33 @@ export default { 'artistsByTrackContributions', 'countsByTrackContributions', artist => - unique([ - ...artist.tracksAsContributor, - ...artist.tracksAsArtist, - ]).length); + (unique( + ([ + artist.trackArtistContributions, + artist.trackContributorContributions, + ]).flat() + .map(({thing}) => thing) + )).length); queryContributionInfo( 'artistsByArtworkContributions', 'countsByArtworkContributions', artist => - artist.tracksAsCoverArtist.length + - artist.albumsAsCoverArtist.length + - artist.albumsAsWallpaperArtist.length + - artist.albumsAsBannerArtist.length); + accumulateSum( + [ + artist.albumCoverArtistContributions, + artist.albumWallpaperArtistContributions, + artist.albumBannerArtistContributions, + artist.trackCoverArtistContributions, + ], + contribs => contribs.length)); if (sprawl.enableFlashesAndGames) { queryContributionInfo( 'artistsByFlashContributions', 'countsByFlashContributions', artist => - artist.flashesAsContributor.length); + artist.flashContributorContributions.length); } return query; diff --git a/src/content/dependencies/listArtistsByGroup.js b/src/content/dependencies/listArtistsByGroup.js index f221fe8c..0bf9dd2d 100644 --- a/src/content/dependencies/listArtistsByGroup.js +++ b/src/content/dependencies/listArtistsByGroup.js @@ -1,10 +1,12 @@ import {sortAlphabetically} from '#sort'; + import { empty, filterByCount, filterMultipleArrays, stitchArrays, transposeArrays, + unique, } from '#sugar'; export default { @@ -32,10 +34,27 @@ export default { // (interesting) groups that each of each artists' things belongs to. const artistThingGroups = artists.map(artist => - ([...artist.albumsAsAny.map(album => album.groups), - ...artist.tracksAsAny.map(track => track.album.groups)]) - .map(groups => groups - .filter(group => interestingGroups.includes(group)))); + ([ + (unique( + ([ + artist.albumArtistContributions, + artist.albumCoverArtistContributions, + artist.albumWallpaperArtistContributions, + artist.albumBannerArtistContributions, + ]).flat() + .map(({thing}) => thing) + )).map(album => album.groups), + (unique( + ([ + artist.trackArtistContributions, + artist.trackContributorContributions, + artist.trackCoverArtistContributions, + ]).flat() + .map(({thing}) => thing) + )).map(track => track.album.groups), + ]).flat() + .map(groups => groups + .filter(group => interestingGroups.includes(group)))); const [artistsByGroup, countsByGroup] = transposeArrays(interestingGroups.map(group => { diff --git a/src/page/artist.js b/src/page/artist.js index f80bd906..b68cf05c 100644 --- a/src/page/artist.js +++ b/src/page/artist.js @@ -9,8 +9,8 @@ export function targets({wikiData}) { export function pathsForTarget(artist) { const hasGalleryPage = - !empty(artist.tracksAsCoverArtist) || - !empty(artist.albumsAsCoverArtist); + !empty(artist.albumCoverArtistContributions) || + !empty(artist.trackCoverArtistContributions); return [ { diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index f8ab3ef3..c0cb5418 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -1,6 +1,6 @@ // Utility functions for interacting with wiki data. -import {accumulateSum, empty} from './sugar.js'; +import {accumulateSum, empty, unique} from './sugar.js'; import {sortByDate} from './sort.js'; // This is a duplicate binding of filterMultipleArrays that's included purely @@ -138,11 +138,20 @@ export function getAllTracks(albumData) { } export function getArtistNumContributions(artist) { - return ( - (artist.tracksAsAny?.length ?? 0) + - (artist.albumsAsCoverArtist?.length ?? 0) + - (artist.flashesAsContributor?.length ?? 0) - ); + return accumulateSum( + [ + unique( + ([ + artist.trackArtistContributions, + artist.trackContributorContributions, + artist.trackCoverArtistContributions, + ]).flat() + .map(({thing}) => thing)), + + artist.albumCoverArtistContributions, + artist.flashContributorContributions, + ], + ({length}) => length); } export function getFlashCover(flash, {to}) { |