Refactoring

This commit is contained in:
syuilo
2018-10-23 05:36:35 +09:00
parent c8b6b6e44f
commit 7c7f32d9a6
32 changed files with 1125 additions and 1111 deletions

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();