1
0

Refactoring: Move chart dir into services dir

This commit is contained in:
syuilo
2019-02-08 04:31:33 +09:00
parent e6612f610c
commit aba85b977d
41 changed files with 53 additions and 53 deletions
+45
View File
@@ -0,0 +1,45 @@
import autobind from 'autobind-decorator';
import Chart from './';
import { IUser, isLocalUser } from '../../models/user';
import { INote } from '../../models/note';
/**
* ユーザーごとのリアクションに関するチャート
*/
type PerUserReactionsLog = {
local: {
/**
* リアクションされた数
*/
count: number;
};
remote: PerUserReactionsLog['local'];
};
class PerUserReactionsChart extends Chart<PerUserReactionsLog> {
constructor() {
super('perUserReaction', true);
}
@autobind
protected async getTemplate(init: boolean, latest?: PerUserReactionsLog, group?: any): Promise<PerUserReactionsLog> {
return {
local: {
count: 0
},
remote: {
count: 0
}
};
}
@autobind
public async update(user: IUser, note: INote) {
this.inc({
[isLocalUser(user) ? 'local' : 'remote']: { count: 1 }
}, note.userId);
}
}
export default new PerUserReactionsChart();