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
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
41 changed files with 53 additions and 53 deletions

View file

@ -1,48 +0,0 @@
import autobind from 'autobind-decorator';
import Chart, { Obj } from '.';
import { IUser, isLocalUser } from '../models/user';
/**
*
*/
type ActiveUsersLog = {
local: {
/**
*
*/
count: number;
};
remote: ActiveUsersLog['local'];
};
class ActiveUsersChart extends Chart<ActiveUsersLog> {
constructor() {
super('activeUsers');
}
@autobind
protected async getTemplate(init: boolean, latest?: ActiveUsersLog): Promise<ActiveUsersLog> {
return {
local: {
count: 0
},
remote: {
count: 0
}
};
}
@autobind
public async update(user: IUser) {
const update: Obj = {
count: 1
};
await this.incIfUnique({
[isLocalUser(user) ? 'local' : 'remote']: update
}, 'users', user._id.toHexString());
}
}
export default new ActiveUsersChart();