diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-02 10:55:38 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 17:26:54 -0300 |
commit | 5f16db8fc0f2b28f2014c439fb299ab34e7d4b1d (patch) | |
tree | 8b16a92879f67b76b65b49f72f5f6ef61643349d /src/content/dependencies | |
parent | 69479b5bff9b88eab7e4b3e7fe972d7ee773dc36 (diff) |
content, page, util: general contributions usage cleanup
Diffstat (limited to 'src/content/dependencies')
7 files changed, 99 insertions, 43 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 => { |