fix federation chart
This commit is contained in:
parent
45c5f0c60a
commit
b929bffea5
@ -0,0 +1,21 @@
|
|||||||
|
export class chartFederationActiveSubPub1646732390560 {
|
||||||
|
name = 'chartFederationActiveSubPub1646732390560'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" DROP COLUMN "___active"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" DROP COLUMN "___active"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" ADD "___subActive" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" ADD "___pubActive" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" ADD "___subActive" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" ADD "___pubActive" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" DROP COLUMN "___pubActive"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" DROP COLUMN "___subActive"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" DROP COLUMN "___pubActive"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" DROP COLUMN "___subActive"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" ADD "___active" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" ADD "___active" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,8 @@ export const schema = {
|
|||||||
'sub': { accumulate: true, range: 'small' },
|
'sub': { accumulate: true, range: 'small' },
|
||||||
'pub': { accumulate: true, range: 'small' },
|
'pub': { accumulate: true, range: 'small' },
|
||||||
'pubsub': { accumulate: true, range: 'small' },
|
'pubsub': { accumulate: true, range: 'small' },
|
||||||
'active': { accumulate: true, range: 'small' },
|
'subActive': { accumulate: true, range: 'small' },
|
||||||
|
'pubActive': { accumulate: true, range: 'small' },
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const entity = Chart.schemaToEntity(name, schema);
|
export const entity = Chart.schemaToEntity(name, schema);
|
||||||
|
@ -2,7 +2,6 @@ import Chart, { KVs } from '../core.js';
|
|||||||
import { Followings, Instances } from '@/models/index.js';
|
import { Followings, Instances } from '@/models/index.js';
|
||||||
import { name, schema } from './entities/federation.js';
|
import { name, schema } from './entities/federation.js';
|
||||||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||||
import { In, MoreThan, Not } from 'typeorm';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* フェデレーションに関するチャート
|
* フェデレーションに関するチャート
|
||||||
@ -29,7 +28,15 @@ export default class FederationChart extends Chart<typeof schema> {
|
|||||||
.select('f.followerHost')
|
.select('f.followerHost')
|
||||||
.where('f.followerHost IS NOT NULL');
|
.where('f.followerHost IS NOT NULL');
|
||||||
|
|
||||||
const [sub, pub, pubsub, active] = await Promise.all([
|
const subInstancesQuery = Followings.createQueryBuilder('f')
|
||||||
|
.select('f.followeeHost')
|
||||||
|
.where('f.followeeHost IS NOT NULL');
|
||||||
|
|
||||||
|
const pubInstancesQuery = Followings.createQueryBuilder('f')
|
||||||
|
.select('f.followerHost')
|
||||||
|
.where('f.followerHost IS NOT NULL');
|
||||||
|
|
||||||
|
const [sub, pub, pubsub, subActive, pubActive] = await Promise.all([
|
||||||
Followings.createQueryBuilder('following')
|
Followings.createQueryBuilder('following')
|
||||||
.select('COUNT(DISTINCT following.followeeHost)')
|
.select('COUNT(DISTINCT following.followeeHost)')
|
||||||
.where('following.followeeHost IS NOT NULL')
|
.where('following.followeeHost IS NOT NULL')
|
||||||
@ -53,18 +60,30 @@ export default class FederationChart extends Chart<typeof schema> {
|
|||||||
.setParameters(pubsubSubQuery.getParameters())
|
.setParameters(pubsubSubQuery.getParameters())
|
||||||
.getRawOne()
|
.getRawOne()
|
||||||
.then(x => parseInt(x.count, 10)),
|
.then(x => parseInt(x.count, 10)),
|
||||||
Instances.count({
|
Instances.createQueryBuilder('instance')
|
||||||
host: Not(In(meta.blockedHosts)),
|
.select('COUNT(instance.id)')
|
||||||
isSuspended: false,
|
.where(`instance.host IN (${ subInstancesQuery.getQuery() })`)
|
||||||
lastCommunicatedAt: MoreThan(new Date(Date.now() - (1000 * 60 * 60 * 24 * 30))),
|
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
|
||||||
}),
|
.andWhere(`instance.isSuspended = false`)
|
||||||
|
.andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
|
||||||
|
.getRawOne()
|
||||||
|
.then(x => parseInt(x.count, 10)),
|
||||||
|
Instances.createQueryBuilder('instance')
|
||||||
|
.select('COUNT(instance.id)')
|
||||||
|
.where(`instance.host IN (${ pubInstancesQuery.getQuery() })`)
|
||||||
|
.andWhere(meta.blockedHosts.length === 0 ? '1=1' : `instance.host NOT IN (:...blocked)`, { blocked: meta.blockedHosts })
|
||||||
|
.andWhere(`instance.isSuspended = false`)
|
||||||
|
.andWhere(`instance.lastCommunicatedAt > :gt`, { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) })
|
||||||
|
.getRawOne()
|
||||||
|
.then(x => parseInt(x.count, 10)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'sub': sub,
|
'sub': sub,
|
||||||
'pub': pub,
|
'pub': pub,
|
||||||
'pubsub': pubsub,
|
'pubsub': pubsub,
|
||||||
'active': active,
|
'subActive': subActive,
|
||||||
|
'pubActive': pubActive,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ const colors = {
|
|||||||
red: '#FF4560',
|
red: '#FF4560',
|
||||||
purple: '#e300db',
|
purple: '#e300db',
|
||||||
orange: '#fe6919',
|
orange: '#fe6919',
|
||||||
lime: '#c7f400',
|
lime: '#bde800',
|
||||||
cyan: '#00efef',
|
cyan: '#00efef',
|
||||||
};
|
};
|
||||||
const colorSets = [colors.blue, colors.green, colors.yellow, colors.red, colors.purple];
|
const colorSets = [colors.blue, colors.green, colors.yellow, colors.red, colors.purple];
|
||||||
@ -390,10 +390,15 @@ export default defineComponent({
|
|||||||
data: format(raw.stalled),
|
data: format(raw.stalled),
|
||||||
color: colors.red,
|
color: colors.red,
|
||||||
}, {
|
}, {
|
||||||
name: 'Active',
|
name: 'Pub Active',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: format(raw.active),
|
data: format(raw.pubActive),
|
||||||
color: colors.lime,
|
color: colors.purple,
|
||||||
|
}, {
|
||||||
|
name: 'Sub Active',
|
||||||
|
type: 'line',
|
||||||
|
data: format(raw.subActive),
|
||||||
|
color: colors.orange,
|
||||||
}, {
|
}, {
|
||||||
name: 'Pub & Sub',
|
name: 'Pub & Sub',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
|
Loading…
Reference in New Issue
Block a user