2022-09-17 18:27:08 +00:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
import { In, MoreThan } from 'typeorm';
|
|
|
|
import { DI } from '@/di-symbols.js';
|
2022-09-20 20:33:11 +00:00
|
|
|
import type { Config } from '@/config.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
import type Logger from '@/logger.js';
|
|
|
|
import FederationChart from '@/core/chart/charts/federation.js';
|
|
|
|
import NotesChart from '@/core/chart/charts/notes.js';
|
|
|
|
import UsersChart from '@/core/chart/charts/users.js';
|
|
|
|
import ActiveUsersChart from '@/core/chart/charts/active-users.js';
|
|
|
|
import InstanceChart from '@/core/chart/charts/instance.js';
|
|
|
|
import PerUserNotesChart from '@/core/chart/charts/per-user-notes.js';
|
|
|
|
import DriveChart from '@/core/chart/charts/drive.js';
|
|
|
|
import PerUserReactionsChart from '@/core/chart/charts/per-user-reactions.js';
|
|
|
|
import HashtagChart from '@/core/chart/charts/hashtag.js';
|
|
|
|
import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
|
|
|
|
import PerUserDriveChart from '@/core/chart/charts/per-user-drive.js';
|
|
|
|
import ApRequestChart from '@/core/chart/charts/ap-request.js';
|
|
|
|
import { QueueLoggerService } from '../QueueLoggerService.js';
|
|
|
|
import type Bull from 'bull';
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class CleanChartsProcessorService {
|
2022-09-18 18:11:50 +00:00
|
|
|
private logger: Logger;
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
@Inject(DI.config)
|
|
|
|
private config: Config,
|
|
|
|
|
|
|
|
private federationChart: FederationChart,
|
|
|
|
private notesChart: NotesChart,
|
|
|
|
private usersChart: UsersChart,
|
|
|
|
private activeUsersChart: ActiveUsersChart,
|
|
|
|
private instanceChart: InstanceChart,
|
|
|
|
private perUserNotesChart: PerUserNotesChart,
|
|
|
|
private driveChart: DriveChart,
|
|
|
|
private perUserReactionsChart: PerUserReactionsChart,
|
|
|
|
private hashtagChart: HashtagChart,
|
|
|
|
private perUserFollowingChart: PerUserFollowingChart,
|
|
|
|
private perUserDriveChart: PerUserDriveChart,
|
|
|
|
private apRequestChart: ApRequestChart,
|
|
|
|
|
|
|
|
private queueLoggerService: QueueLoggerService,
|
|
|
|
) {
|
2022-09-18 18:11:50 +00:00
|
|
|
this.logger = this.queueLoggerService.logger.createSubLogger('clean-charts');
|
2022-09-17 18:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public async process(job: Bull.Job<Record<string, unknown>>, done: () => void): Promise<void> {
|
2022-09-18 18:11:50 +00:00
|
|
|
this.logger.info('Clean charts...');
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
this.federationChart.clean(),
|
|
|
|
this.notesChart.clean(),
|
|
|
|
this.usersChart.clean(),
|
|
|
|
this.activeUsersChart.clean(),
|
|
|
|
this.instanceChart.clean(),
|
|
|
|
this.perUserNotesChart.clean(),
|
|
|
|
this.driveChart.clean(),
|
|
|
|
this.perUserReactionsChart.clean(),
|
|
|
|
this.hashtagChart.clean(),
|
|
|
|
this.perUserFollowingChart.clean(),
|
|
|
|
this.perUserDriveChart.clean(),
|
|
|
|
this.apRequestChart.clean(),
|
|
|
|
]);
|
|
|
|
|
2022-09-18 18:11:50 +00:00
|
|
|
this.logger.succ('All charts successfully cleaned.');
|
2022-09-17 18:27:08 +00:00
|
|
|
done();
|
|
|
|
}
|
|
|
|
}
|