Skipping joins for aggregated actor fetch.
This commit is contained in:
@@ -208,8 +208,16 @@ export function sortActorsByGender(actors, context = {}) {
|
|||||||
export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
||||||
const [actors, profiles, photos, socials, stashes, alerts] = await Promise.all([
|
const [actors, profiles, photos, socials, stashes, alerts] = await Promise.all([
|
||||||
knex('actors')
|
knex('actors')
|
||||||
|
.select('actors.*')
|
||||||
|
.whereIn('actors.id', actorIds)
|
||||||
|
.modify((builder) => {
|
||||||
|
if (options.order) {
|
||||||
|
builder.orderBy(...options.order);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.shallow) {
|
||||||
|
builder
|
||||||
.select(
|
.select(
|
||||||
'actors.*',
|
|
||||||
'actors_meta.stashed',
|
'actors_meta.stashed',
|
||||||
knex.raw('row_to_json(avatars) as avatar'),
|
knex.raw('row_to_json(avatars) as avatar'),
|
||||||
'birth_countries.alpha2 as birth_country_alpha2',
|
'birth_countries.alpha2 as birth_country_alpha2',
|
||||||
@@ -225,13 +233,9 @@ export async function fetchActorsById(actorIds, options = {}, reqUser) {
|
|||||||
.leftJoin('media as avatars', 'avatars.id', 'actors.avatar_media_id')
|
.leftJoin('media as avatars', 'avatars.id', 'actors.avatar_media_id')
|
||||||
.leftJoin('media as sfw_media', 'sfw_media.id', 'avatars.sfw_media_id')
|
.leftJoin('media as sfw_media', 'sfw_media.id', 'avatars.sfw_media_id')
|
||||||
.leftJoin('entities', 'entities.id', 'actors.entity_id')
|
.leftJoin('entities', 'entities.id', 'actors.entity_id')
|
||||||
.whereIn('actors.id', actorIds)
|
.groupBy('actors.id', 'avatars.id', 'sfw_media.id', 'entities.id', 'actors_meta.stashed', 'birth_countries.alpha2', 'residence_countries.alpha2');
|
||||||
.modify((builder) => {
|
|
||||||
if (options.order) {
|
|
||||||
builder.orderBy(...options.order);
|
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
.groupBy('actors.id', 'avatars.id', 'sfw_media.id', 'entities.id', 'actors_meta.stashed', 'birth_countries.alpha2', 'residence_countries.alpha2'),
|
|
||||||
knex('actors_profiles')
|
knex('actors_profiles')
|
||||||
.select(
|
.select(
|
||||||
'actors_profiles.*',
|
'actors_profiles.*',
|
||||||
|
|||||||
Reference in New Issue
Block a user