fix: skip if pinnedNotes are empty

This commit is contained in:
Namekuji 2023-09-28 03:52:43 -04:00
parent 93a500be0d
commit 668a8a1429
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532
2 changed files with 12 additions and 10 deletions

View file

@ -60,7 +60,7 @@ export class Cache<T> {
if (keys.length === 0) { if (keys.length === 0) {
return map; return map;
} }
keys = keys.map((key) => key.slice(redisPrefix?.length)); keys = keys.map((key) => key.slice(redisPrefix.length));
const values = await redisClient.mgetBuffer(keys); const values = await redisClient.mgetBuffer(keys);
for (const [i, key] of keys.entries()) { for (const [i, key] of keys.entries()) {

View file

@ -422,15 +422,17 @@ export const UserRepository = db.getRepository(User).extend({
}, },
}).then((notes) => notes.map(({ noteId }) => noteId)); }).then((notes) => notes.map(({ noteId }) => noteId));
if (scyllaClient) { if (pinnedNoteIds.length > 0) {
const result = await scyllaClient.execute( if (scyllaClient) {
prepared.note.select.byIds, const result = await scyllaClient.execute(
[pinnedNoteIds], prepared.note.select.byIds,
{ prepare: true }, [pinnedNoteIds],
); { prepare: true },
pinnedNotes = result.rows.map(parseScyllaNote); );
} else { pinnedNotes = result.rows.map(parseScyllaNote);
pinnedNotes = await Notes.findBy({ id: In(pinnedNoteIds) }); } else {
pinnedNotes = await Notes.findBy({ id: In(pinnedNoteIds) });
}
} }
} }