summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/ReactionService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-10-19 09:20:19 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-10-19 09:20:19 +0900
commit1671575d5d3d081c83f172f3439884010aafeb59 (patch)
tree662c64008c53d3290269ed5b69ceb8e773d60837 /packages/backend/src/core/ReactionService.ts
parentperf(backend): improve my reaction population performance (diff)
downloadmisskey-1671575d5d3d081c83f172f3439884010aafeb59.tar.gz
misskey-1671575d5d3d081c83f172f3439884010aafeb59.tar.bz2
misskey-1671575d5d3d081c83f172f3439884010aafeb59.zip
perf(backend): ノートのリアクション情報をキャッシュすることでDBへのクエリを削減
Diffstat (limited to 'packages/backend/src/core/ReactionService.ts')
-rw-r--r--packages/backend/src/core/ReactionService.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts
index 1458e2b173..edf433025d 100644
--- a/packages/backend/src/core/ReactionService.ts
+++ b/packages/backend/src/core/ReactionService.ts
@@ -187,6 +187,9 @@ export class ReactionService {
await this.notesRepository.createQueryBuilder().update()
.set({
reactions: () => sql,
+ ...(note.reactionAndUserPairCache.length < 10 ? {
+ reactionAndUserPairCache: () => `array_append("reactionAndUserPairCache", '${user.id}:${reaction}')`,
+ } : {}),
})
.where('id = :id', { id: note.id })
.execute();
@@ -293,6 +296,7 @@ export class ReactionService {
await this.notesRepository.createQueryBuilder().update()
.set({
reactions: () => sql,
+ reactionAndUserPairCache: () => `array_remove("reactionAndUserPairCache", '${user.id}:${exist.reaction}')`,
})
.where('id = :id', { id: note.id })
.execute();