From 3a7558f36c4c035c96e4b9a96c1ae0889b8ae308 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Oct 2023 07:59:46 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=203=E6=97=A5=E4=BB=A5?= =?UTF-8?q?=E5=86=85=E3=81=AB=E6=8A=95=E7=A8=BF=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=88=E3=81=AE=E3=81=BF=E3=83=8F=E3=82=A4?= =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=88=E7=94=A8=E3=82=B9=E3=82=B3=E3=82=A2?= =?UTF-8?q?=E5=8A=A0=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/NoteCreateService.ts | 4 ++-- packages/backend/src/core/ReactionService.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 5e8644394..4a454e79e 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -726,8 +726,8 @@ export class NoteCreateService implements OnApplicationShutdown { .where('id = :id', { id: renote.id }) .execute(); - // 30%の確率でハイライト用ランキング更新 - if (Math.random() < 0.3) { + // 30%の確率、3日以内に投稿されたノートの場合ハイライト用ランキング更新 + if (Math.random() < 0.3 && (Date.now() - this.idService.parse(renote.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3) { if (renote.channelId != null) { if (renote.replyId == null) { this.featuredService.updateInChannelNotesRanking(renote.channelId, renote.id, 5); diff --git a/packages/backend/src/core/ReactionService.ts b/packages/backend/src/core/ReactionService.ts index 86213e457..e7bbd4492 100644 --- a/packages/backend/src/core/ReactionService.ts +++ b/packages/backend/src/core/ReactionService.ts @@ -192,8 +192,12 @@ export class ReactionService { .where('id = :id', { id: note.id }) .execute(); - // 30%の確率でハイライト用ランキング更新 - if (Math.random() < 0.3 && note.userId !== user.id) { + // 30%の確率、セルフではない、3日以内に投稿されたノートの場合ハイライト用ランキング更新 + if ( + Math.random() < 0.3 && + note.userId !== user.id && + (Date.now() - this.idService.parse(note.id).date.getTime()) < 1000 * 60 * 60 * 24 * 3 + ) { if (note.channelId != null) { if (note.replyId == null) { this.featuredService.updateInChannelNotesRanking(note.channelId, note.id, 1);