fix: take more than requested
This commit is contained in:
parent
5828fa7a14
commit
618dc8349c
6 changed files with 73 additions and 20 deletions
|
@ -280,6 +280,8 @@ export function prepareNoteQuery(ps: {
|
|||
queryParts.push(`AND "createdAt" > ?`);
|
||||
}
|
||||
|
||||
queryParts.push("LIMIT 100");
|
||||
|
||||
const query = queryParts.join(" ");
|
||||
|
||||
return {
|
||||
|
|
|
@ -138,10 +138,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return filtered;
|
||||
};
|
||||
|
||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
const foundPacked = [];
|
||||
while (foundPacked.length < ps.limit) {
|
||||
const foundNotes = (await execNotePaginationQuery(ps, filter)).slice(
|
||||
0,
|
||||
ps.limit * 1.5,
|
||||
); // Some may filtered out by Notes.packMany, thus we take more than ps.limit.
|
||||
foundPacked.push(
|
||||
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
||||
);
|
||||
if (foundNotes.length < ps.limit) break;
|
||||
ps.untilDate = foundNotes[foundNotes.length - 1].createdAt.getTime();
|
||||
}
|
||||
|
||||
return foundPacked.slice(0, ps.limit);
|
||||
}
|
||||
|
||||
//#region Construct query
|
||||
|
|
|
@ -165,10 +165,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return filtered;
|
||||
};
|
||||
|
||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
const foundPacked = [];
|
||||
while (foundPacked.length < ps.limit) {
|
||||
const foundNotes = (await execNotePaginationQuery(ps, filter)).slice(
|
||||
0,
|
||||
ps.limit * 1.5,
|
||||
); // Some may filtered out by Notes.packMany, thus we take more than ps.limit.
|
||||
foundPacked.push(
|
||||
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
||||
);
|
||||
if (foundNotes.length < ps.limit) break;
|
||||
ps.untilDate = foundNotes[foundNotes.length - 1].createdAt.getTime();
|
||||
}
|
||||
|
||||
return foundPacked.slice(0, ps.limit);
|
||||
}
|
||||
|
||||
//#region Construct query
|
||||
|
|
|
@ -180,10 +180,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return filtered;
|
||||
};
|
||||
|
||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
const foundPacked = [];
|
||||
while (foundPacked.length < ps.limit) {
|
||||
const foundNotes = (await execNotePaginationQuery(ps, filter)).slice(
|
||||
0,
|
||||
ps.limit * 1.5,
|
||||
); // Some may filtered out by Notes.packMany, thus we take more than ps.limit.
|
||||
foundPacked.push(
|
||||
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
||||
);
|
||||
if (foundNotes.length < ps.limit) break;
|
||||
ps.untilDate = foundNotes[foundNotes.length - 1].createdAt.getTime();
|
||||
}
|
||||
|
||||
return foundPacked.slice(0, ps.limit);
|
||||
}
|
||||
|
||||
//#region Construct query
|
||||
|
|
|
@ -102,10 +102,21 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return filtered;
|
||||
};
|
||||
|
||||
const foundNotes = await execNotePaginationQuery(ps, filter, 1);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
const foundPacked = [];
|
||||
let untilDate: number | undefined;
|
||||
while (foundPacked.length < ps.limit) {
|
||||
const foundNotes = (await execNotePaginationQuery({...ps, untilDate}, filter)).slice(
|
||||
0,
|
||||
ps.limit * 1.5,
|
||||
); // Some may filtered out by Notes.packMany, thus we take more than ps.limit.
|
||||
foundPacked.push(
|
||||
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
||||
);
|
||||
if (foundNotes.length < ps.limit) break;
|
||||
untilDate = foundNotes[foundNotes.length - 1].createdAt.getTime();
|
||||
}
|
||||
|
||||
return foundPacked.slice(0, ps.limit);
|
||||
}
|
||||
|
||||
const query = makePaginationQuery(
|
||||
|
|
|
@ -152,10 +152,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
return filtered;
|
||||
};
|
||||
|
||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
||||
scyllaNote: true,
|
||||
});
|
||||
const foundPacked = [];
|
||||
while (foundPacked.length < ps.limit) {
|
||||
const foundNotes = (await execNotePaginationQuery(ps, filter)).slice(
|
||||
0,
|
||||
ps.limit * 1.5,
|
||||
); // Some may filtered out by Notes.packMany, thus we take more than ps.limit.
|
||||
foundPacked.push(
|
||||
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
||||
);
|
||||
if (foundNotes.length < ps.limit) break;
|
||||
ps.untilDate = foundNotes[foundNotes.length - 1].createdAt.getTime();
|
||||
}
|
||||
|
||||
return foundPacked.slice(0, ps.limit);
|
||||
}
|
||||
|
||||
const hasFollowing = await followingsCache.exists();
|
||||
|
|
Loading…
Reference in a new issue