enhance(server): delete outdated hard-mutes regularly to improve db performance

This commit is contained in:
syuilo 2022-12-22 08:29:18 +09:00
parent 1fd9ba8dcb
commit ad4d8b07d3
2 changed files with 12 additions and 1 deletions

View File

@ -26,6 +26,7 @@ You should also include the user name that made the change.
- Server: improve syslog performance @syuilo
- Server: improve note scoring for featured notes @CyberRex0
- Server: delete outdated notifications regularly to improve db performance @syuilo
- Server: delete outdated hard-mutes regularly to improve db performance @syuilo
- Client: use tabler-icons instead of fontawesome to better design @syuilo
- Client: Add new gabber kick sounds (thanks for noizenecio)
- Client: Compress non-animated PNG files @saschanaz

View File

@ -1,10 +1,11 @@
import { Inject, Injectable } from '@nestjs/common';
import { In, LessThan, MoreThan } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { NotificationsRepository, UserIpsRepository } from '@/models/index.js';
import type { MutedNotesRepository, NotificationsRepository, UserIpsRepository } from '@/models/index.js';
import type { Config } from '@/config.js';
import type Logger from '@/logger.js';
import { bindThis } from '@/decorators.js';
import { IdService } from '@/core/IdService.js';
import { QueueLoggerService } from '../QueueLoggerService.js';
import type Bull from 'bull';
@ -22,7 +23,11 @@ export class CleanProcessorService {
@Inject(DI.notificationsRepository)
private notificationsRepository: NotificationsRepository,
@Inject(DI.mutedNotesRepository)
private mutedNotesRepository: MutedNotesRepository,
private queueLoggerService: QueueLoggerService,
private idService: IdService,
) {
this.logger = this.queueLoggerService.logger.createSubLogger('clean');
}
@ -39,6 +44,11 @@ export class CleanProcessorService {
createdAt: LessThan(new Date(Date.now() - (1000 * 60 * 60 * 24 * 90))),
});
this.mutedNotesRepository.delete({
id: LessThan(this.idService.genId(new Date(Date.now() - (1000 * 60 * 60 * 24 * 90)))),
reason: 'word',
});
this.logger.succ('Cleaned.');
done();
}