Improve chart engine (#8253)
* wip * wip * wip * wip * wip * wip * wip * Update core.ts * wip * wip * #7361 * delete network chart * federationChart強化 apRequestChart追加 * tweak
This commit is contained in:
@ -261,6 +261,11 @@ export default function() {
|
||||
}, {
|
||||
repeat: { cron: '0 0 * * *' },
|
||||
});
|
||||
|
||||
systemQueue.add('cleanCharts', {
|
||||
}, {
|
||||
repeat: { cron: '0 0 * * *' },
|
||||
});
|
||||
}
|
||||
|
||||
export function destroy() {
|
||||
|
@ -4,7 +4,7 @@ import request from '@/remote/activitypub/request';
|
||||
import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
|
||||
import Logger from '@/services/logger';
|
||||
import { Instances } from '@/models/index';
|
||||
import { instanceChart } from '@/services/chart/index';
|
||||
import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index';
|
||||
import { fetchInstanceMetadata } from '@/services/fetch-instance-metadata';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { toPuny } from '@/misc/convert-host';
|
||||
@ -61,6 +61,8 @@ export default async (job: Bull.Job<DeliverJobData>) => {
|
||||
fetchInstanceMetadata(i);
|
||||
|
||||
instanceChart.requestSent(i.host, true);
|
||||
apRequestChart.deliverSucc();
|
||||
federationChart.deliverd(i.host);
|
||||
});
|
||||
|
||||
return 'Success';
|
||||
@ -74,6 +76,7 @@ export default async (job: Bull.Job<DeliverJobData>) => {
|
||||
});
|
||||
|
||||
instanceChart.requestSent(i.host, false);
|
||||
apRequestChart.deliverFail();
|
||||
});
|
||||
|
||||
if (res instanceof StatusError) {
|
||||
|
@ -5,7 +5,7 @@ import perform from '@/remote/activitypub/perform';
|
||||
import Logger from '@/services/logger';
|
||||
import { registerOrFetchInstanceDoc } from '@/services/register-or-fetch-instance-doc';
|
||||
import { Instances } from '@/models/index';
|
||||
import { instanceChart } from '@/services/chart/index';
|
||||
import { apRequestChart, federationChart, instanceChart } from '@/services/chart/index';
|
||||
import { fetchMeta } from '@/misc/fetch-meta';
|
||||
import { toPuny, extractDbHost } from '@/misc/convert-host';
|
||||
import { getApId } from '@/remote/activitypub/type';
|
||||
@ -143,6 +143,8 @@ export default async (job: Bull.Job<InboxJobData>): Promise<string> => {
|
||||
fetchInstanceMetadata(i);
|
||||
|
||||
instanceChart.requestReceived(i.host);
|
||||
apRequestChart.inbox();
|
||||
federationChart.inbox(i.host);
|
||||
});
|
||||
|
||||
// アクティビティを処理
|
||||
|
28
packages/backend/src/queue/processors/system/clean-charts.ts
Normal file
28
packages/backend/src/queue/processors/system/clean-charts.ts
Normal file
@ -0,0 +1,28 @@
|
||||
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> {
|
||||
logger.info(`Resync charts...`);
|
||||
|
||||
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();
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
import * as Bull from 'bull';
|
||||
import { resyncCharts } from './resync-charts';
|
||||
import { cleanCharts } from './clean-charts';
|
||||
|
||||
const jobs = {
|
||||
resyncCharts,
|
||||
cleanCharts,
|
||||
} as Record<string, Bull.ProcessCallbackFunction<Record<string, unknown>> | Bull.ProcessPromiseFunction<Record<string, unknown>>>;
|
||||
|
||||
export default function(dbQueue: Bull.Queue<Record<string, unknown>>) {
|
||||
|
Reference in New Issue
Block a user