enhance(backend): tweak hashtag trend
This commit is contained in:
parent
0fe8c0134c
commit
dc435fb8ee
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import * as Redis from 'ioredis';
|
import * as Redis from 'ioredis';
|
||||||
import { getLineAndCharacterOfPosition } from 'typescript';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { MiUser } from '@/models/User.js';
|
import type { MiUser } from '@/models/User.js';
|
||||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||||
|
@ -15,6 +14,7 @@ import type { HashtagsRepository } from '@/models/_.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { FeaturedService } from '@/core/FeaturedService.js';
|
import { FeaturedService } from '@/core/FeaturedService.js';
|
||||||
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HashtagService {
|
export class HashtagService {
|
||||||
|
@ -28,6 +28,7 @@ export class HashtagService {
|
||||||
private userEntityService: UserEntityService,
|
private userEntityService: UserEntityService,
|
||||||
private featuredService: FeaturedService,
|
private featuredService: FeaturedService,
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
|
private metaService: MetaService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +158,9 @@ export class HashtagService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async updateHashtagsRanking(hashtag: string, userId: MiUser['id']): Promise<void> {
|
public async updateHashtagsRanking(hashtag: string, userId: MiUser['id']): Promise<void> {
|
||||||
// TODO: instance.hiddenTagsの考慮
|
const instance = await this.metaService.fetch();
|
||||||
|
const hiddenTags = instance.hiddenTags.map(t => normalizeForSearch(t));
|
||||||
|
if (hiddenTags.includes(hashtag)) return;
|
||||||
|
|
||||||
// YYYYMMDDHHmm (10分間隔)
|
// YYYYMMDDHHmm (10分間隔)
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { FeaturedService } from '@/core/FeaturedService.js';
|
import { FeaturedService } from '@/core/FeaturedService.js';
|
||||||
import { HashtagService } from '@/core/HashtagService.js';
|
import { HashtagService } from '@/core/HashtagService.js';
|
||||||
|
@ -55,14 +53,10 @@ export const paramDef = {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||||
constructor(
|
constructor(
|
||||||
private metaService: MetaService,
|
|
||||||
private featuredService: FeaturedService,
|
private featuredService: FeaturedService,
|
||||||
private hashtagService: HashtagService,
|
private hashtagService: HashtagService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async () => {
|
super(meta, paramDef, async () => {
|
||||||
const instance = await this.metaService.fetch(true);
|
|
||||||
const hiddenTags = instance.hiddenTags.map(t => normalizeForSearch(t));
|
|
||||||
|
|
||||||
const ranking = await this.featuredService.getHashtagsRanking(10);
|
const ranking = await this.featuredService.getHashtagsRanking(10);
|
||||||
|
|
||||||
const charts = ranking.length === 0 ? {} : await this.hashtagService.getCharts(ranking, 20);
|
const charts = ranking.length === 0 ? {} : await this.hashtagService.getCharts(ranking, 20);
|
||||||
|
|
Loading…
Reference in a new issue