summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-10-06 16:10:59 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-10-06 16:10:59 +0900
commit132b01461d65e58508ab0206eddf09119bec46bd (patch)
treea0b032540ddb494dff40b0a2ba77f8d98069bb1a /packages/backend/src
parentenhance(backend): improve featured system (diff)
downloadsharkey-132b01461d65e58508ab0206eddf09119bec46bd.tar.gz
sharkey-132b01461d65e58508ab0206eddf09119bec46bd.tar.bz2
sharkey-132b01461d65e58508ab0206eddf09119bec46bd.zip
refactor
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/FeaturedService.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/backend/src/core/FeaturedService.ts b/packages/backend/src/core/FeaturedService.ts
index 89b86b2e30..78309e42e5 100644
--- a/packages/backend/src/core/FeaturedService.ts
+++ b/packages/backend/src/core/FeaturedService.ts
@@ -9,6 +9,8 @@ import type { MiNote } from '@/models/_.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
+const GLOBAL_NOTES_RANKING_WINDOW = 1000 * 60 * 60 * 24 * 3; // 3日ごと
+
@Injectable()
export class FeaturedService {
constructor(
@@ -26,7 +28,7 @@ export class FeaturedService {
@bindThis
private getCurrentGlobalNotesRankingWindow(): number {
const passed = new Date().getTime() - new Date(new Date().getFullYear(), 0, 1).getTime();
- return Math.floor(passed / (1000 * 60 * 60 * 24 * 3)); // 3日ごと
+ return Math.floor(passed / GLOBAL_NOTES_RANKING_WINDOW);
}
@bindThis
@@ -40,7 +42,7 @@ export class FeaturedService {
noteId);
redisTransaction.expire(
`featuredGlobalNotesRanking:${currentWindow}`,
- 60 * 60 * 24 * 9, // 9日間保持
+ (GLOBAL_NOTES_RANKING_WINDOW * 3) / 1000,
'NX'); // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
await redisTransaction.exec();
}
@@ -55,7 +57,7 @@ export class FeaturedService {
noteId);
redisTransaction.expire(
`featuredInChannelNotesRanking:${channelId}:${currentWindow}`,
- 60 * 60 * 24 * 9, // 9日間保持
+ (GLOBAL_NOTES_RANKING_WINDOW * 3) / 1000,
'NX'); // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定
await redisTransaction.exec();
}