reduce log spam from charts

This commit is contained in:
Hazelnoot 2024-11-14 20:25:48 -05:00
parent 41536480ce
commit 0f6d26e065
2 changed files with 11 additions and 4 deletions

View file

@ -6,6 +6,8 @@
import { Injectable } from '@nestjs/common';
import { bindThis } from '@/decorators.js';
import { ChartLoggerService } from '@/core/chart/ChartLoggerService.js';
import Logger from '@/logger.js';
import FederationChart from './charts/federation.js';
import NotesChart from './charts/notes.js';
import UsersChart from './charts/users.js';
@ -24,6 +26,7 @@ import type { OnApplicationShutdown } from '@nestjs/common';
export class ChartManagementService implements OnApplicationShutdown {
private charts;
private saveIntervalId: NodeJS.Timeout;
private readonly logger: Logger;
constructor(
private federationChart: FederationChart,
@ -38,6 +41,7 @@ export class ChartManagementService implements OnApplicationShutdown {
private perUserFollowingChart: PerUserFollowingChart,
private perUserDriveChart: PerUserDriveChart,
private apRequestChart: ApRequestChart,
private chartLoggerService: ChartLoggerService,
) {
this.charts = [
this.federationChart,
@ -53,6 +57,7 @@ export class ChartManagementService implements OnApplicationShutdown {
this.perUserDriveChart,
this.apRequestChart,
];
this.logger = chartLoggerService.logger;
}
@bindThis
@ -62,6 +67,7 @@ export class ChartManagementService implements OnApplicationShutdown {
for (const chart of this.charts) {
chart.save();
}
this.logger.info('All charts saved');
}, 1000 * 60 * 20);
}
@ -72,6 +78,7 @@ export class ChartManagementService implements OnApplicationShutdown {
await Promise.all(
this.charts.map(chart => chart.save()),
);
this.logger.info('All charts saved');
}
}