From a9a245b46104429912168e9c6806fe7c61727a61 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 22 Dec 2022 08:32:01 +0900 Subject: [PATCH] enhance(server): delete outdated notes of antenna regularly to improve db performance --- CHANGELOG.md | 1 + .../src/queue/processors/CleanProcessorService.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20db04f3e..74d6efd66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ You should also include the user name that made the change. - 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 +- Server: delete outdated notes of antenna 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 diff --git a/packages/backend/src/queue/processors/CleanProcessorService.ts b/packages/backend/src/queue/processors/CleanProcessorService.ts index 9836065aa..4aa1dc15f 100644 --- a/packages/backend/src/queue/processors/CleanProcessorService.ts +++ b/packages/backend/src/queue/processors/CleanProcessorService.ts @@ -1,7 +1,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { In, LessThan, MoreThan } from 'typeorm'; import { DI } from '@/di-symbols.js'; -import type { MutedNotesRepository, NotificationsRepository, UserIpsRepository } from '@/models/index.js'; +import type { AntennaNotesRepository, MutedNotesRepository, NotificationsRepository, UserIpsRepository } from '@/models/index.js'; import type { Config } from '@/config.js'; import type Logger from '@/logger.js'; import { bindThis } from '@/decorators.js'; @@ -26,6 +26,9 @@ export class CleanProcessorService { @Inject(DI.mutedNotesRepository) private mutedNotesRepository: MutedNotesRepository, + @Inject(DI.antennaNotesRepository) + private antennaNotesRepository: AntennaNotesRepository, + private queueLoggerService: QueueLoggerService, private idService: IdService, ) { @@ -49,6 +52,10 @@ export class CleanProcessorService { reason: 'word', }); + this.antennaNotesRepository.delete({ + id: LessThan(this.idService.genId(new Date(Date.now() - (1000 * 60 * 60 * 24 * 90)))), + }); + this.logger.succ('Cleaned.'); done(); }