Added actors pagination.
This commit is contained in:
@@ -62,20 +62,23 @@ export async function fetchActorsById(actorIds) {
|
||||
.groupBy('actors.id', 'avatars.id'),
|
||||
]);
|
||||
|
||||
return actorIds.map((actorId) => {
|
||||
const curatedActors = actorIds.map((actorId) => {
|
||||
const actor = actors.find((actorEntry) => actorEntry.id === actorId);
|
||||
|
||||
if (!actor) {
|
||||
console.warn(`Can't find ${actorId}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return curateActor(actor);
|
||||
}).filter(Boolean);
|
||||
|
||||
return curatedActors;
|
||||
}
|
||||
|
||||
function curateOptions(options) {
|
||||
if (options?.limit > 100) {
|
||||
throw new HttpError('Limit must be <= 100', 400);
|
||||
if (options?.limit > 120) {
|
||||
throw new HttpError('Limit must be <= 120', 400);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -108,8 +111,6 @@ function buildQuery(filters) {
|
||||
|
||||
['gender', 'country'].forEach((attribute) => {
|
||||
if (filters[attribute]) {
|
||||
console.log(attribute, filters[attribute]);
|
||||
|
||||
query.bool.must.push({
|
||||
equals: {
|
||||
[attribute]: filters[attribute],
|
||||
@@ -197,6 +198,9 @@ export async function fetchActors(filters, rawOptions) {
|
||||
const options = curateOptions(rawOptions);
|
||||
const { query, expressions } = buildQuery(filters);
|
||||
|
||||
console.log(options);
|
||||
console.log('offset', (options.page - 1) * options.limit);
|
||||
|
||||
const result = await searchApi.search({
|
||||
index: 'actors',
|
||||
query,
|
||||
|
||||
Reference in New Issue
Block a user