diff options
Diffstat (limited to 'packages/backend/src/services/chart')
| -rw-r--r-- | packages/backend/src/services/chart/charts/entities/federation.ts | 1 | ||||
| -rw-r--r-- | packages/backend/src/services/chart/charts/federation.ts | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/packages/backend/src/services/chart/charts/entities/federation.ts b/packages/backend/src/services/chart/charts/entities/federation.ts index 6b2089f0b4..3ed5d7352a 100644 --- a/packages/backend/src/services/chart/charts/entities/federation.ts +++ b/packages/backend/src/services/chart/charts/entities/federation.ts @@ -8,6 +8,7 @@ export const schema = { 'stalled': { uniqueIncrement: true, range: 'small' }, 'sub': { accumulate: true, range: 'small' }, 'pub': { accumulate: true, range: 'small' }, + 'pubsub': { accumulate: true, range: 'small' }, } as const; export const entity = Chart.schemaToEntity(name, schema); diff --git a/packages/backend/src/services/chart/charts/federation.ts b/packages/backend/src/services/chart/charts/federation.ts index 211ba1debc..020f89fe72 100644 --- a/packages/backend/src/services/chart/charts/federation.ts +++ b/packages/backend/src/services/chart/charts/federation.ts @@ -20,7 +20,11 @@ export default class FederationChart extends Chart<typeof schema> { @autobind protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> { - const [sub, pub] = await Promise.all([ + const pubsubSubQuery = Followings.createQueryBuilder('f') + .select('f.followerHost') + .where('f.followerHost IS NOT NULL'); + + const [sub, pub, pubsub] = await Promise.all([ Followings.createQueryBuilder('following') .select('COUNT(DISTINCT following.followeeHost)') .where('following.followeeHost IS NOT NULL') @@ -31,11 +35,19 @@ export default class FederationChart extends Chart<typeof schema> { .where('following.followerHost IS NOT NULL') .getRawOne() .then(x => parseInt(x.count, 10)), + Followings.createQueryBuilder('following') + .select('COUNT(DISTINCT following.followeeHost)') + .where('following.followeeHost IS NOT NULL') + .andWhere(`following.followerHost IN (${ pubsubSubQuery.getQuery() })`) + .setParameters(pubsubSubQuery.getParameters()) + .getRawOne() + .then(x => parseInt(x.count, 10)), ]); return { 'sub': sub, 'pub': pub, + 'pubsub': pubsub, }; } |