summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/FeaturedService.ts
diff options
context:
space:
mode:
authorzyoshoka <107108195+zyoshoka@users.noreply.github.com>2023-11-26 10:05:56 +0900
committerGitHub <noreply@github.com>2023-11-26 10:05:56 +0900
commit2ee48ae04da540384214ff0d7c8df2dfb18c88fc (patch)
tree2a32f6298d23b610134b6bd0fc8414206c9ed0d1 /packages/backend/src/core/FeaturedService.ts
parentfix(backend): rename FunoutTimelineService to FanoutTimelineService (#12453) (diff)
downloadsharkey-2ee48ae04da540384214ff0d7c8df2dfb18c88fc.tar.gz
sharkey-2ee48ae04da540384214ff0d7c8df2dfb18c88fc.tar.bz2
sharkey-2ee48ae04da540384214ff0d7c8df2dfb18c88fc.zip
fix(backend): ギャラリーの人気の投稿の選出にidを用いるように (#12448)
Diffstat (limited to 'packages/backend/src/core/FeaturedService.ts')
-rw-r--r--packages/backend/src/core/FeaturedService.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/backend/src/core/FeaturedService.ts b/packages/backend/src/core/FeaturedService.ts
index 9617f83880..507fc464ff 100644
--- a/packages/backend/src/core/FeaturedService.ts
+++ b/packages/backend/src/core/FeaturedService.ts
@@ -5,11 +5,12 @@
import { Inject, Injectable } from '@nestjs/common';
import * as Redis from 'ioredis';
-import type { MiNote, MiUser } from '@/models/_.js';
+import type { MiGalleryPost, MiNote, MiUser } 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日ごと
+export const GALLERY_POSTS_RANKING_WINDOW = 1000 * 60 * 60 * 24 * 3; // 3日ごと
const PER_USER_NOTES_RANKING_WINDOW = 1000 * 60 * 60 * 24 * 7; // 1週間ごと
const HASHTAG_RANKING_WINDOW = 1000 * 60 * 60; // 1時間ごと
@@ -80,6 +81,11 @@ export class FeaturedService {
}
@bindThis
+ public updateGalleryPostsRanking(galleryPostId: MiGalleryPost['id'], score = 1): Promise<void> {
+ return this.updateRankingOf('featuredGalleryPostsRanking', GALLERY_POSTS_RANKING_WINDOW, galleryPostId, score);
+ }
+
+ @bindThis
public updateInChannelNotesRanking(channelId: MiNote['channelId'], noteId: MiNote['id'], score = 1): Promise<void> {
return this.updateRankingOf(`featuredInChannelNotesRanking:${channelId}`, GLOBAL_NOTES_RANKING_WINDOW, noteId, score);
}
@@ -100,6 +106,11 @@ export class FeaturedService {
}
@bindThis
+ public getGalleryPostsRanking(threshold: number): Promise<MiGalleryPost['id'][]> {
+ return this.getRankingOf('featuredGalleryPostsRanking', GALLERY_POSTS_RANKING_WINDOW, threshold);
+ }
+
+ @bindThis
public getInChannelNotesRanking(channelId: MiNote['channelId'], threshold: number): Promise<MiNote['id'][]> {
return this.getRankingOf(`featuredInChannelNotesRanking:${channelId}`, GLOBAL_NOTES_RANKING_WINDOW, threshold);
}