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
|
@ -101,6 +101,7 @@
|
||||||
- Fix: 「みつける」が年越し時に壊れる問題を修正
|
- Fix: 「みつける」が年越し時に壊れる問題を修正
|
||||||
- Fix: アカウントをブロックした際に、自身のユーザーのページでノートが相手に表示される問題を修正
|
- Fix: アカウントをブロックした際に、自身のユーザーのページでノートが相手に表示される問題を修正
|
||||||
- Fix: モデレーションログがモデレーターは閲覧できないように修正
|
- Fix: モデレーションログがモデレーターは閲覧できないように修正
|
||||||
|
- Fix: ハッシュタグのトレンド除外設定が即時に効果を持つように修正
|
||||||
- Fix: HTTP Digestヘッダのアルゴリズム部分に大文字の"SHA-256"しか使えない
|
- Fix: HTTP Digestヘッダのアルゴリズム部分に大文字の"SHA-256"しか使えない
|
||||||
- Fix: 管理者用APIのアクセス権限が適切に設定されていない問題を修正
|
- Fix: 管理者用APIのアクセス権限が適切に設定されていない問題を修正
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,17 @@ export class FeaturedService {
|
||||||
return Array.from(ranking.keys());
|
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
|
@bindThis
|
||||||
public updateGlobalNotesRanking(noteId: MiNote['id'], score = 1): Promise<void> {
|
public updateGlobalNotesRanking(noteId: MiNote['id'], score = 1): Promise<void> {
|
||||||
return this.updateRankingOf('featuredGlobalNotesRanking', GLOBAL_NOTES_RANKING_WINDOW, noteId, score);
|
return this.updateRankingOf('featuredGlobalNotesRanking', GLOBAL_NOTES_RANKING_WINDOW, noteId, score);
|
||||||
|
@ -126,4 +137,9 @@ export class FeaturedService {
|
||||||
public getHashtagsRanking(threshold: number): Promise<string[]> {
|
public getHashtagsRanking(threshold: number): Promise<string[]> {
|
||||||
return this.getRankingOf('featuredHashtagsRanking', HASHTAG_RANKING_WINDOW, threshold);
|
return this.getRankingOf('featuredHashtagsRanking', HASHTAG_RANKING_WINDOW, threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public removeHashtagsFromRanking(hashtag: string): Promise<void> {
|
||||||
|
return this.removeFromRanking('featuredHashtagsRanking', HASHTAG_RANKING_WINDOW, hashtag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import { MiMeta } from '@/models/Meta.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
|
import { FeaturedService } from '@/core/FeaturedService.js';
|
||||||
import type { OnApplicationShutdown } from '@nestjs/common';
|
import type { OnApplicationShutdown } from '@nestjs/common';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -25,6 +26,7 @@ export class MetaService implements OnApplicationShutdown {
|
||||||
@Inject(DI.db)
|
@Inject(DI.db)
|
||||||
private db: DataSource,
|
private db: DataSource,
|
||||||
|
|
||||||
|
private featuredService: FeaturedService,
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
//this.onMessage = this.onMessage.bind(this);
|
//this.onMessage = this.onMessage.bind(this);
|
||||||
|
@ -95,6 +97,8 @@ export class MetaService implements OnApplicationShutdown {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async update(data: Partial<MiMeta>): Promise<MiMeta> {
|
public async update(data: Partial<MiMeta>): Promise<MiMeta> {
|
||||||
|
let before: MiMeta | undefined;
|
||||||
|
|
||||||
const updated = await this.db.transaction(async transactionalEntityManager => {
|
const updated = await this.db.transaction(async transactionalEntityManager => {
|
||||||
const metas = await transactionalEntityManager.find(MiMeta, {
|
const metas = await transactionalEntityManager.find(MiMeta, {
|
||||||
order: {
|
order: {
|
||||||
|
@ -102,10 +106,10 @@ export class MetaService implements OnApplicationShutdown {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const meta = metas[0];
|
before = metas[0];
|
||||||
|
|
||||||
if (meta) {
|
if (before) {
|
||||||
await transactionalEntityManager.update(MiMeta, meta.id, data);
|
await transactionalEntityManager.update(MiMeta, before.id, data);
|
||||||
|
|
||||||
const metas = await transactionalEntityManager.find(MiMeta, {
|
const metas = await transactionalEntityManager.find(MiMeta, {
|
||||||
order: {
|
order: {
|
||||||
|
@ -119,6 +123,21 @@ export class MetaService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (data.hiddenTags) {
|
||||||
|
process.nextTick(() => {
|
||||||
|
const hiddenTags = new Set<string>(data.hiddenTags);
|
||||||
|
if (before) {
|
||||||
|
for (const previousHiddenTag of before.hiddenTags) {
|
||||||
|
hiddenTags.delete(previousHiddenTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const hiddenTag of hiddenTags) {
|
||||||
|
this.featuredService.removeHashtagsFromRanking(hiddenTag);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.globalEventService.publishInternalEvent('metaUpdated', updated);
|
this.globalEventService.publishInternalEvent('metaUpdated', updated);
|
||||||
|
|
||||||
return updated;
|
return updated;
|
||||||
|
|
Loading…
Reference in New Issue