2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-08-05 03:33:00 +02:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2022-09-17 20:27:08 +02:00
|
|
|
import type Logger from '@/logger.js';
|
|
|
|
import NotesChart from '@/core/chart/charts/notes.js';
|
|
|
|
import UsersChart from '@/core/chart/charts/users.js';
|
|
|
|
import DriveChart from '@/core/chart/charts/drive.js';
|
2023-02-03 06:10:14 +01:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2022-09-17 20:27:08 +02:00
|
|
|
import { QueueLoggerService } from '../QueueLoggerService.js';
|
2023-05-29 04:54:49 +02:00
|
|
|
import type * as Bull from 'bullmq';
|
2022-09-17 20:27:08 +02:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ResyncChartsProcessorService {
|
2022-09-18 20:11:50 +02:00
|
|
|
private logger: Logger;
|
2022-09-17 20:27:08 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private notesChart: NotesChart,
|
|
|
|
private usersChart: UsersChart,
|
|
|
|
private driveChart: DriveChart,
|
|
|
|
private queueLoggerService: QueueLoggerService,
|
|
|
|
) {
|
2022-09-18 20:11:50 +02:00
|
|
|
this.logger = this.queueLoggerService.logger.createSubLogger('resync-charts');
|
2022-09-17 20:27:08 +02:00
|
|
|
}
|
|
|
|
|
2022-12-04 07:03:09 +01:00
|
|
|
@bindThis
|
2023-05-29 04:54:49 +02:00
|
|
|
public async process(): Promise<void> {
|
2022-09-18 20:11:50 +02:00
|
|
|
this.logger.info('Resync charts...');
|
2022-09-17 20:27:08 +02:00
|
|
|
|
|
|
|
// TODO: ユーザーごとのチャートも更新する
|
|
|
|
// TODO: インスタンスごとのチャートも更新する
|
|
|
|
await Promise.all([
|
|
|
|
this.driveChart.resync(),
|
|
|
|
this.notesChart.resync(),
|
|
|
|
this.usersChart.resync(),
|
|
|
|
]);
|
|
|
|
|
2022-09-18 20:11:50 +02:00
|
|
|
this.logger.succ('All charts successfully resynced.');
|
2022-09-17 20:27:08 +02:00
|
|
|
}
|
|
|
|
}
|