1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-18 16:48:30 +09:00
cherrypick/packages/backend/src/queue/processors/CleanChartsProcessorService.ts

74 lines
2.5 KiB
TypeScript
Raw Normal View History

/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
2022-09-18 03:27:08 +09:00
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
2022-09-21 05:33:11 +09:00
import type { Config } from '@/config.js';
2022-09-18 03:27:08 +09: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';
2023-01-01 17:45:49 +09:00
import PerUserPvChart from '@/core/chart/charts/per-user-pv.js';
2022-09-18 03:27:08 +09:00
import DriveChart from '@/core/chart/charts/drive.js';
import PerUserReactionsChart from '@/core/chart/charts/per-user-reactions.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';
2023-01-01 17:45:49 +09:00
import { bindThis } from '@/decorators.js';
2022-09-18 03:27:08 +09:00
import { QueueLoggerService } from '../QueueLoggerService.js';
import type * as Bull from 'bullmq';
2022-09-18 03:27:08 +09:00
@Injectable()
export class CleanChartsProcessorService {
2022-09-19 03:11:50 +09:00
private logger: Logger;
2022-09-18 03:27:08 +09: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,
2023-01-01 17:45:49 +09:00
private perUserPvChart: PerUserPvChart,
2022-09-18 03:27:08 +09:00
private driveChart: DriveChart,
private perUserReactionsChart: PerUserReactionsChart,
private perUserFollowingChart: PerUserFollowingChart,
private perUserDriveChart: PerUserDriveChart,
private apRequestChart: ApRequestChart,
private queueLoggerService: QueueLoggerService,
) {
2022-09-19 03:11:50 +09:00
this.logger = this.queueLoggerService.logger.createSubLogger('clean-charts');
2022-09-18 03:27:08 +09:00
}
@bindThis
public async process(): Promise<void> {
2022-09-19 03:11:50 +09:00
this.logger.info('Clean charts...');
2022-09-18 03:27:08 +09:00
await Promise.all([
this.federationChart.clean(),
this.notesChart.clean(),
this.usersChart.clean(),
this.activeUsersChart.clean(),
this.instanceChart.clean(),
this.perUserNotesChart.clean(),
2023-01-01 17:45:49 +09:00
this.perUserPvChart.clean(),
2022-09-18 03:27:08 +09:00
this.driveChart.clean(),
this.perUserReactionsChart.clean(),
this.perUserFollowingChart.clean(),
this.perUserDriveChart.clean(),
this.apRequestChart.clean(),
]);
2022-09-19 03:11:50 +09:00
this.logger.succ('All charts successfully cleaned.');
2022-09-18 03:27:08 +09:00
}
}