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(`AND "createdAt" > ?`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
queryParts.push("LIMIT 100");
|
||||||
|
|
||||||
const query = queryParts.join(" ");
|
const query = queryParts.join(" ");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -138,10 +138,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
return filtered;
|
return filtered;
|
||||||
};
|
};
|
||||||
|
|
||||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
const foundPacked = [];
|
||||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
while (foundPacked.length < ps.limit) {
|
||||||
scyllaNote: true,
|
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
|
//#region Construct query
|
||||||
|
|
|
@ -165,10 +165,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
return filtered;
|
return filtered;
|
||||||
};
|
};
|
||||||
|
|
||||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
const foundPacked = [];
|
||||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
while (foundPacked.length < ps.limit) {
|
||||||
scyllaNote: true,
|
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
|
//#region Construct query
|
||||||
|
|
|
@ -180,10 +180,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
return filtered;
|
return filtered;
|
||||||
};
|
};
|
||||||
|
|
||||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
const foundPacked = [];
|
||||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
while (foundPacked.length < ps.limit) {
|
||||||
scyllaNote: true,
|
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
|
//#region Construct query
|
||||||
|
|
|
@ -102,10 +102,21 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
return filtered;
|
return filtered;
|
||||||
};
|
};
|
||||||
|
|
||||||
const foundNotes = await execNotePaginationQuery(ps, filter, 1);
|
const foundPacked = [];
|
||||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
let untilDate: number | undefined;
|
||||||
scyllaNote: true,
|
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(
|
const query = makePaginationQuery(
|
||||||
|
|
|
@ -152,10 +152,20 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
return filtered;
|
return filtered;
|
||||||
};
|
};
|
||||||
|
|
||||||
const foundNotes = await execNotePaginationQuery(ps, filter);
|
const foundPacked = [];
|
||||||
return await Notes.packMany(foundNotes.slice(0, ps.limit), user, {
|
while (foundPacked.length < ps.limit) {
|
||||||
scyllaNote: true,
|
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();
|
const hasFollowing = await followingsCache.exists();
|
||||||
|
|
Loading…
Reference in a new issue