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,6 +422,7 @@ export const UserRepository = db.getRepository(User).extend({
}, },
}).then((notes) => notes.map(({ noteId }) => noteId)); }).then((notes) => notes.map(({ noteId }) => noteId));
if (pinnedNoteIds.length > 0) {
if (scyllaClient) { if (scyllaClient) {
const result = await scyllaClient.execute( const result = await scyllaClient.execute(
prepared.note.select.byIds, prepared.note.select.byIds,
@ -433,6 +434,7 @@ export const UserRepository = db.getRepository(User).extend({
pinnedNotes = await Notes.findBy({ id: In(pinnedNoteIds) }); pinnedNotes = await Notes.findBy({ id: In(pinnedNoteIds) });
} }
} }
}
const profile = opts.detail const profile = opts.detail
? await UserProfiles.findOneByOrFail({ userId: user.id }) ? await UserProfiles.findOneByOrFail({ userId: user.id })