1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-25 12:08:16 +09:00
MisskeyIO/src/chart/per-user-reactions.ts

46 lines
920 B
TypeScript
Raw Normal View History

2018-10-23 05:36:35 +09:00
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();