chore: remove hashtag from featured immediately (#12668)
* chore: remove hashtag from featured immediately * docs(changelog): ハッシュタグのトレンド除外設定が即時に効果を持つように修正 --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
757dee5664
commit
b2254a66d3
3 changed files with 39 additions and 3 deletions
|
@ -77,6 +77,17 @@ export class FeaturedService {
|
|||
return Array.from(ranking.keys());
|
||||
}
|
||||
|
||||
@bindThis
|
||||
private async removeFromRanking(name: string, windowRange: number, element: string): Promise<void> {
|
||||
const currentWindow = this.getCurrentWindow(windowRange);
|
||||
const previousWindow = currentWindow - 1;
|
||||
|
||||
const redisPipeline = this.redisClient.pipeline();
|
||||
redisPipeline.zrem(`${name}:${currentWindow}`, element);
|
||||
redisPipeline.zrem(`${name}:${previousWindow}`, element);
|
||||
await redisPipeline.exec();
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public updateGlobalNotesRanking(noteId: MiNote['id'], score = 1): Promise<void> {
|
||||
return this.updateRankingOf('featuredGlobalNotesRanking', GLOBAL_NOTES_RANKING_WINDOW, noteId, score);
|
||||
|
@ -126,4 +137,9 @@ export class FeaturedService {
|
|||
public getHashtagsRanking(threshold: number): Promise<string[]> {
|
||||
return this.getRankingOf('featuredHashtagsRanking', HASHTAG_RANKING_WINDOW, threshold);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public removeHashtagsFromRanking(hashtag: string): Promise<void> {
|
||||
return this.removeFromRanking('featuredHashtagsRanking', HASHTAG_RANKING_WINDOW, hashtag);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue