Skip to content

Commit

Permalink
enhance(server): delete outdated notes of antenna regularly to improv…
Browse files Browse the repository at this point in the history
…e db performance
  • Loading branch information
syuilo committed Dec 21, 2022
1 parent ad4d8b0 commit a9a245b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
@@ -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';
Expand All @@ -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,
) {
Expand All @@ -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();
}
Expand Down

0 comments on commit a9a245b

Please sign in to comment.