Skip to content
Snippets Groups Projects
clean-charts.ts 922 B
Newer Older
syuilo's avatar
syuilo committed
import * as Bull from 'bull';

import { queueLogger } from '../../logger';
import { activeUsersChart, driveChart, federationChart, hashtagChart, instanceChart, notesChart, perUserDriveChart, perUserFollowingChart, perUserNotesChart, perUserReactionsChart, usersChart, apRequestChart } from '@/services/chart/index';

const logger = queueLogger.createSubLogger('clean-charts');

export async function cleanCharts(job: Bull.Job<Record<string, unknown>>, done: any): Promise<void> {
syuilo's avatar
syuilo committed
	logger.info(`Clean charts...`);
syuilo's avatar
syuilo committed

	await Promise.all([
		federationChart.clean(),
		notesChart.clean(),
		usersChart.clean(),
		activeUsersChart.clean(),
		instanceChart.clean(),
		perUserNotesChart.clean(),
		driveChart.clean(),
		perUserReactionsChart.clean(),
		hashtagChart.clean(),
		perUserFollowingChart.clean(),
		perUserDriveChart.clean(),
		apRequestChart.clean(),
	]);

	logger.succ(`All charts successfully cleaned.`);
	done();
}