Improved scene actors filter.
This commit is contained in:
@@ -31,6 +31,7 @@ export function curateActor(actor, context = {}) {
|
||||
isS3: actor.avatar.is_s3,
|
||||
},
|
||||
likes: actor.stashed,
|
||||
...context.append?.[actor.id],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ export async function fetchActorsById(actorIds, options = {}) {
|
||||
]);
|
||||
|
||||
if (options.order) {
|
||||
return actors.map((actorEntry) => curateActor(actorEntry));
|
||||
return actors.map((actorEntry) => curateActor(actorEntry, { append: options.append }));
|
||||
}
|
||||
|
||||
const curatedActors = actorIds.map((actorId) => {
|
||||
@@ -69,7 +70,7 @@ export async function fetchActorsById(actorIds, options = {}) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return curateActor(actor);
|
||||
return curateActor(actor, { append: options.append });
|
||||
}).filter(Boolean);
|
||||
|
||||
return curatedActors;
|
||||
|
||||
@@ -238,8 +238,10 @@ export async function fetchScenes(filters, rawOptions) {
|
||||
}),
|
||||
});
|
||||
|
||||
const actorCounts = result.aggregations?.actorIds && Object.fromEntries(result.aggregations?.actorIds?.buckets.map((bucket) => [bucket.key, { count: bucket.doc_count }]));
|
||||
|
||||
const [actors] = await Promise.all([
|
||||
options.aggregate ? fetchActorsById(result.aggregations.actorIds.buckets.map((bucket) => bucket.key), { order: ['name', 'asc'] }) : [],
|
||||
result.aggregations?.actorIds ? fetchActorsById(result.aggregations.actorIds.buckets.map((bucket) => bucket.key), { order: ['name', 'asc'], append: actorCounts }) : [],
|
||||
]);
|
||||
|
||||
const sceneIds = result.hits.hits.map((hit) => Number(hit._id));
|
||||
|
||||
Reference in New Issue
Block a user