1
0
Files
pawkey-sk/packages/backend/src/services/chart/charts/per-user-reactions.ts
T
syuilo c1b264e4e9 Improve chart engine (#8253)
* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update core.ts

* wip

* wip

* #7361

* delete network chart

* federationChart強化 apRequestChart追加

* tweak
2022-02-06 00:13:52 +09:00

30 lines
885 B
TypeScript

import autobind from 'autobind-decorator';
import Chart, { KVs } from '../core';
import { User } from '@/models/entities/user';
import { Note } from '@/models/entities/note';
import { Users } from '@/models/index';
import { name, schema } from './entities/per-user-reactions';
/**
* ユーザーごとのリアクションに関するチャート
*/
// eslint-disable-next-line import/no-default-export
export default class PerUserReactionsChart extends Chart<typeof schema> {
constructor() {
super(name, schema, true);
}
@autobind
protected async queryCurrentState(group: string): Promise<Partial<KVs<typeof schema>>> {
return {};
}
@autobind
public async update(user: { id: User['id'], host: User['host'] }, note: Note): Promise<void> {
const prefix = Users.isLocalUser(user) ? 'local' : 'remote';
this.commit({
[`${prefix}.count`]: 1,
}, note.userId);
}
}