From e1e83994e0209dff6b3ccd17ecfe0c0b54ec3e85 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sun, 1 Mar 2026 05:08:51 +0100 Subject: [PATCH] Don't fetch actor assets for scene and movie aggregations. --- src/actors.js | 19 +++++++++++-------- src/movies.js | 2 +- src/scenes.js | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/actors.js b/src/actors.js index 50bc577..400d917 100644 --- a/src/actors.js +++ b/src/actors.js @@ -271,12 +271,15 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) { .where('user_id', reqUser.id) .whereIn('actor_id', actorIds) : [], - ]); + ].slice(0, options.shallow ? 1 : -1)); if (options.order) { return actors.map((actorEntry) => curateActor(actorEntry, { - stashes: stashes.filter((stash) => stash.actor_id === actorEntry.id), - alerts: alerts.filter((alert) => alert.actor_id === actorEntry.id), + stashes: stashes?.filter((stash) => stash.actor_id === actorEntry.id), + alerts: alerts?.filter((alert) => alert.actor_id === actorEntry.id), + profiles: profiles?.filter((profile) => profile.actor_id === actorEntry.id), + photos: photos?.filter((photo) => photo.actor_id === actorEntry.id), + socials: socials?.filter((social) => social.actor_id === actorEntry.id), append: options.append, })); } @@ -290,11 +293,11 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) { } return curateActor(actor, { - stashes: stashes.filter((stash) => stash.actor_id === actor.id), - alerts: alerts.filter((alert) => alert.actor_id === actor.id), - profiles: profiles.filter((profile) => profile.actor_id === actor.id), - photos: photos.filter((photo) => photo.actor_id === actor.id), - socials: socials.filter((social) => social.actor_id === actor.id), + stashes: stashes?.filter((stash) => stash.actor_id === actor.id), + alerts: alerts?.filter((alert) => alert.actor_id === actor.id), + profiles: profiles?.filter((profile) => profile.actor_id === actor.id), + photos: photos?.filter((photo) => photo.actor_id === actor.id), + socials: socials?.filter((social) => social.actor_id === actor.id), append: options.append, }); }).filter(Boolean); diff --git a/src/movies.js b/src/movies.js index 4b97651..ecd6a58 100644 --- a/src/movies.js +++ b/src/movies.js @@ -421,7 +421,7 @@ export async function fetchMovies(filters, rawOptions, reqUser, context) { const channelCounts = options.aggregateChannels && countAggregations(result.aggregations?.channelIds); const [aggActors, aggTags, aggChannels] = await Promise.all([ - options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: actorCounts }, reqUser) : [], + options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { shadllow: true, order: ['slug', 'asc'], append: actorCounts }, reqUser) : [], options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(name)'), 'asc'], append: tagCounts }, reqUser, context) : [], options.aggregateChannels ? fetchEntitiesById(result.aggregations.channelIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: channelCounts }, reqUser, context) : [], ]); diff --git a/src/scenes.js b/src/scenes.js index 1f95185..9198a87 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -649,7 +649,7 @@ export async function fetchScenes(filters, rawOptions, reqUser, context) { console.time('fetch aggregations'); const [aggActors, aggTags, aggChannels] = await Promise.all([ - options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: actorCounts }, reqUser) : [], + options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { shallow: true, order: ['slug', 'asc'], append: actorCounts }, reqUser) : [], options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(name)'), 'asc'], append: tagCounts }, reqUser, context) : [], options.aggregateChannels ? fetchEntitiesById(entityIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: channelCounts }, reqUser, context) : [], ]);