summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-04-06 18:27:42 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-04-06 18:27:42 +0900
commitde9d136a3f5477535d0f0825f907bfb988c6d69d (patch)
tree36d010487c628bf09166a57b7f0456a2dc47b8f1 /packages/backend/src
parentUpdate about-misskey.vue (diff)
downloadmisskey-de9d136a3f5477535d0f0825f907bfb988c6d69d.tar.gz
misskey-de9d136a3f5477535d0f0825f907bfb988c6d69d.tar.bz2
misskey-de9d136a3f5477535d0f0825f907bfb988c6d69d.zip
perf(backend): reduce db query
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/entities/NoteEntityService.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts
index 94b3029c58..1320e56ca2 100644
--- a/packages/backend/src/core/entities/NoteEntityService.ts
+++ b/packages/backend/src/core/entities/NoteEntityService.ts
@@ -183,6 +183,11 @@ export class NoteEntityService implements OnModuleInit {
// 実装上抜けがあるだけかもしれないので、「ヒントに含まれてなかったら(=undefinedなら)return」のようにはしない
}
+ // パフォーマンスのためノートが作成されてから1秒以上経っていない場合はリアクションを取得しない
+ if (note.createdAt.getTime() + 1000 > Date.now()) {
+ return undefined;
+ }
+
const reaction = await this.noteReactionsRepository.findOneBy({
userId: meId,
noteId: note.id,
@@ -395,7 +400,8 @@ export class NoteEntityService implements OnModuleInit {
const myReactionsMap = new Map<Note['id'], NoteReaction | null>();
if (meId) {
const renoteIds = notes.filter(n => n.renoteId != null).map(n => n.renoteId!);
- const targets = [...notes.map(n => n.id), ...renoteIds];
+ // パフォーマンスのためノートが作成されてから1秒以上経っていない場合はリアクションを取得しない
+ const targets = [...notes.filter(n => n.createdAt.getTime() + 1000 < Date.now()).map(n => n.id), ...renoteIds];
const myReactions = await this.noteReactionsRepository.findBy({
userId: meId,
noteId: In(targets),