mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-14 14:15:43 +01:00
feat: add pub & sub item for federation chart
This commit is contained in:
parent
65be8daa15
commit
a28daf7f44
5 changed files with 49 additions and 14 deletions
|
@ -17,6 +17,7 @@ You should also include the user name that made the change.
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
- プロフィールの追加情報を最大16まで保存できるように
|
- プロフィールの追加情報を最大16まで保存できるように
|
||||||
|
- 連合チャートにPub&Subを追加
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
- Client: リアクションピッカーの高さが低くなったまま戻らないことがあるのを修正 @syuilo
|
- Client: リアクションピッカーの高さが低くなったまま戻らないことがあるのを修正 @syuilo
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
const { MigrationInterface, QueryRunner } = require("typeorm");
|
||||||
|
|
||||||
|
module.exports = class federationChartPubsub1645599900873 {
|
||||||
|
name = 'federationChartPubsub1645599900873'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" ADD "___pubsub" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" ADD "___pubsub" smallint NOT NULL DEFAULT '0'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart_day__federation" DROP COLUMN "___pubsub"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "__chart__federation" DROP COLUMN "___pubsub"`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,7 @@ export const schema = {
|
||||||
'stalled': { uniqueIncrement: true, range: 'small' },
|
'stalled': { uniqueIncrement: true, range: 'small' },
|
||||||
'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' },
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
export const entity = Chart.schemaToEntity(name, schema);
|
export const entity = Chart.schemaToEntity(name, schema);
|
||||||
|
|
|
@ -20,7 +20,11 @@ export default class FederationChart extends Chart<typeof schema> {
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
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')
|
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')
|
||||||
|
@ -31,11 +35,19 @@ export default class FederationChart extends Chart<typeof schema> {
|
||||||
.where('following.followerHost IS NOT NULL')
|
.where('following.followerHost IS NOT NULL')
|
||||||
.getRawOne()
|
.getRawOne()
|
||||||
.then(x => parseInt(x.count, 10)),
|
.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 {
|
return {
|
||||||
'sub': sub,
|
'sub': sub,
|
||||||
'pub': pub,
|
'pub': pub,
|
||||||
|
'pubsub': pubsub,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ const colors = {
|
||||||
red: '#FF4560',
|
red: '#FF4560',
|
||||||
purple: '#e300db',
|
purple: '#e300db',
|
||||||
orange: '#fe6919',
|
orange: '#fe6919',
|
||||||
|
lime: '#c7f400',
|
||||||
};
|
};
|
||||||
const colorSets = [colors.blue, colors.green, colors.yellow, colors.red, colors.purple];
|
const colorSets = [colors.blue, colors.green, colors.yellow, colors.red, colors.purple];
|
||||||
const getColor = (i) => {
|
const getColor = (i) => {
|
||||||
|
@ -224,7 +225,7 @@ export default defineComponent({
|
||||||
axis: 'y',
|
axis: 'y',
|
||||||
colors: {
|
colors: {
|
||||||
0: alpha(x.color ? x.color : getColor(i), 0),
|
0: alpha(x.color ? x.color : getColor(i), 0),
|
||||||
[maxes[i]]: alpha(x.color ? x.color : getColor(i), 0.15),
|
[maxes[i]]: alpha(x.color ? x.color : getColor(i), 0.175),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -373,16 +374,6 @@ export default defineComponent({
|
||||||
const raw = await os.api('charts/federation', { limit: props.limit, span: props.span });
|
const raw = await os.api('charts/federation', { limit: props.limit, span: props.span });
|
||||||
return {
|
return {
|
||||||
series: [{
|
series: [{
|
||||||
name: 'Sub',
|
|
||||||
type: 'area',
|
|
||||||
data: format(raw.sub),
|
|
||||||
color: colors.orange,
|
|
||||||
}, {
|
|
||||||
name: 'Pub',
|
|
||||||
type: 'area',
|
|
||||||
data: format(raw.pub),
|
|
||||||
color: colors.purple,
|
|
||||||
}, {
|
|
||||||
name: 'Received',
|
name: 'Received',
|
||||||
type: 'area',
|
type: 'area',
|
||||||
data: format(raw.inboxInstances),
|
data: format(raw.inboxInstances),
|
||||||
|
@ -397,6 +388,21 @@ export default defineComponent({
|
||||||
type: 'area',
|
type: 'area',
|
||||||
data: format(raw.stalled),
|
data: format(raw.stalled),
|
||||||
color: colors.red,
|
color: colors.red,
|
||||||
|
}, {
|
||||||
|
name: 'Pub & Sub',
|
||||||
|
type: 'area',
|
||||||
|
data: format(raw.pubsub),
|
||||||
|
color: colors.lime,
|
||||||
|
}, {
|
||||||
|
name: 'Pub',
|
||||||
|
type: 'area',
|
||||||
|
data: format(raw.pub),
|
||||||
|
color: colors.purple,
|
||||||
|
}, {
|
||||||
|
name: 'Sub',
|
||||||
|
type: 'area',
|
||||||
|
data: format(raw.sub),
|
||||||
|
color: colors.orange,
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -529,12 +535,12 @@ export default defineComponent({
|
||||||
name: 'Write',
|
name: 'Write',
|
||||||
type: 'area',
|
type: 'area',
|
||||||
data: format(raw.write),
|
data: format(raw.write),
|
||||||
color: colors.blue,
|
color: colors.lime,
|
||||||
}, {
|
}, {
|
||||||
name: 'Read',
|
name: 'Read',
|
||||||
type: 'area',
|
type: 'area',
|
||||||
data: format(raw.read),
|
data: format(raw.read),
|
||||||
color: '#888888',
|
color: colors.blue,
|
||||||
}, {
|
}, {
|
||||||
name: '< Week',
|
name: '< Week',
|
||||||
type: 'area',
|
type: 'area',
|
||||||
|
|
Loading…
Reference in a new issue