From 329830e2c3d1d46de712d1cbe4cf3bac51144dcb Mon Sep 17 00:00:00 2001 From: syuilo <Syuilotan@yahoo.co.jp> Date: Sat, 14 Oct 2023 10:05:44 +0900 Subject: [PATCH] perf(backend): tweak populateMyReaction --- packages/backend/src/core/entities/NoteEntityService.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 25132977f2..316367f23a 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -180,8 +180,8 @@ export class NoteEntityService implements OnModuleInit { // 実装上抜ã‘ãŒã‚ã‚‹ã ã‘ã‹ã‚‚ã—ã‚Œãªã„ã®ã§ã€ã€Œãƒ’ントã«å«ã¾ã‚Œã¦ãªã‹ã£ãŸã‚‰(=undefinedãªã‚‰)returnã€ã®ã‚ˆã†ã«ã¯ã—ãªã„ } - // パフォーマンスã®ãŸã‚ノートãŒä½œæˆã•ã‚Œã¦ã‹ã‚‰1秒以上経ã£ã¦ã„ãªã„å ´åˆã¯ãƒªã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’å–å¾—ã—ãªã„ - if (note.createdAt.getTime() + 1000 > Date.now()) { + // パフォーマンスã®ãŸã‚ノートãŒä½œæˆã•ã‚Œã¦ã‹ã‚‰2秒以上経ã£ã¦ã„ãªã„å ´åˆã¯ãƒªã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’å–å¾—ã—ãªã„ + if (note.createdAt.getTime() + 2000 > Date.now()) { return undefined; } @@ -382,8 +382,8 @@ export class NoteEntityService implements OnModuleInit { const myReactionsMap = new Map<MiNote['id'], MiNoteReaction | null>(); if (meId) { const renoteIds = notes.filter(n => n.renoteId != null).map(n => n.renoteId!); - // パフォーマンスã®ãŸã‚ノートãŒä½œæˆã•ã‚Œã¦ã‹ã‚‰1秒以上経ã£ã¦ã„ãªã„å ´åˆã¯ãƒªã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’å–å¾—ã—ãªã„ - const targets = [...notes.filter(n => n.createdAt.getTime() + 1000 < Date.now()).map(n => n.id), ...renoteIds]; + // パフォーマンスã®ãŸã‚ノートãŒä½œæˆã•ã‚Œã¦ã‹ã‚‰2秒以上経ã£ã¦ã„ãªã„å ´åˆã¯ãƒªã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã‚’å–å¾—ã—ãªã„ + const targets = [...notes.filter(n => n.createdAt.getTime() + 2000 < Date.now()).map(n => n.id), ...renoteIds]; const myReactions = await this.noteReactionsRepository.findBy({ userId: meId, noteId: In(targets), -- GitLab