From ec45db7870c0e157e9069bd2bceb1329c136a9fa Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 19 Oct 2023 11:19:42 +0900 Subject: [PATCH] refactor and perf tweak --- packages/backend/src/core/ReactionService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts index f3f2b04dd6..4233b8d4c3 100644 --- a/packages/backend/src/core/ReactionService.ts +++ b/packages/backend/src/core/ReactionService.ts @@ -30,6 +30,7 @@ import { RoleService } from '@/core/RoleService.js'; import { FeaturedService } from '@/core/FeaturedService.js'; const FALLBACK = '❤'; +const PER_NOTE_REACTION_USER_PAIR_CACHE_MAX = 16; const legacies: Record = { 'like': '👍', @@ -187,7 +188,7 @@ export class ReactionService { await this.notesRepository.createQueryBuilder().update() .set({ reactions: () => sql, - ...(note.reactionAndUserPairCache.length < 10 ? { + ...(note.reactionAndUserPairCache.length < PER_NOTE_REACTION_USER_PAIR_CACHE_MAX ? { reactionAndUserPairCache: () => `array_append("reactionAndUserPairCache", '${user.id}/${reaction}')`, } : {}), })