perf: query home and local
This commit is contained in:
parent
3e4961445f
commit
030294a10d
1 changed files with 8 additions and 5 deletions
|
@ -125,7 +125,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
UserBlockedCache.init(user.id).then((cache) => cache.getAll()),
|
UserBlockedCache.init(user.id).then((cache) => cache.getAll()),
|
||||||
RenoteMutingsCache.init(user.id).then((cache) => cache.getAll()),
|
RenoteMutingsCache.init(user.id).then((cache) => cache.getAll()),
|
||||||
]);
|
]);
|
||||||
const validUserIds = [user.id].concat(followingUserIds);
|
const validUserIds = [user.id, ...followingUserIds];
|
||||||
const optFilter = (n: ScyllaNote) =>
|
const optFilter = (n: ScyllaNote) =>
|
||||||
!n.renoteId || !!n.text || n.files.length > 0 || n.hasPoll;
|
!n.renoteId || !!n.text || n.files.length > 0 || n.hasPoll;
|
||||||
|
|
||||||
|
@ -167,10 +167,13 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
|
|
||||||
const foundPacked = [];
|
const foundPacked = [];
|
||||||
while (foundPacked.length < ps.limit) {
|
while (foundPacked.length < ps.limit) {
|
||||||
const foundNotes = (await execNotePaginationQuery("global", ps, filter)).slice(
|
const [homeFoundNotes, localFoundNotes] = await Promise.all([
|
||||||
0,
|
execNotePaginationQuery("home", ps, filter, user.id),
|
||||||
ps.limit * 1.5,
|
execNotePaginationQuery("local", ps, filter),
|
||||||
); // Some may filtered out by Notes.packMany, thus we take more than ps.limit.
|
]);
|
||||||
|
const foundNotes = [...homeFoundNotes, ...localFoundNotes]
|
||||||
|
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
|
||||||
|
.slice(0, ps.limit * 1.5); // Some may be filtered out by Notes.packMany, thus we take more than ps.limit.
|
||||||
foundPacked.push(
|
foundPacked.push(
|
||||||
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
...(await Notes.packMany(foundNotes, user, { scyllaNote: true })),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue