mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 09:05:06 -07:00
cleanup and support for all address types
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { Cron, CronExpression } from '@nestjs/schedule';
|
||||
|
||||
import { ClientStatisticsService } from '../ORM/client-statistics/client-statistics.service';
|
||||
import { ClientService } from '../ORM/client/client.service';
|
||||
|
||||
@Injectable()
|
||||
export class CleanupService implements OnModuleInit {
|
||||
|
||||
constructor(
|
||||
private clientStatisticsService: ClientStatisticsService,
|
||||
private clientService: ClientService
|
||||
) {
|
||||
|
||||
}
|
||||
onModuleInit() {
|
||||
console.log('Cleanup service running.')
|
||||
}
|
||||
|
||||
@Cron(CronExpression.EVERY_HOUR)
|
||||
private async deleteOldStatistics() {
|
||||
const deletedStatistics = await this.clientStatisticsService.deleteOldStatistics();
|
||||
console.log(`Deleted ${deletedStatistics.affected} old statistics`);
|
||||
const deletedClients = await this.clientService.deleteOldClients();
|
||||
console.log(`Deleted ${deletedClients.affected} old clients`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user