Improve chart performance (#7360)
* wip * wip * wip * wip * wip * Update chart.ts * wip * Improve server performance * wip * wip
This commit is contained in:
parent
0d19c2d42e
commit
4f249159d3
32 changed files with 889 additions and 161 deletions
|
|
@ -17,6 +17,18 @@ export default class ActiveUsersChart extends Chart<ActiveUsersLog> {
|
|||
return {};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected aggregate(logs: ActiveUsersLog[]): ActiveUsersLog {
|
||||
return {
|
||||
local: {
|
||||
users: logs.reduce((a, b) => a.concat(b.local.users), [] as ActiveUsersLog['local']['users']),
|
||||
},
|
||||
remote: {
|
||||
users: logs.reduce((a, b) => a.concat(b.remote.users), [] as ActiveUsersLog['remote']['users']),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@autobind
|
||||
protected async fetchActual(): Promise<DeepPartial<ActiveUsersLog>> {
|
||||
return {};
|
||||
|
|
@ -25,11 +37,11 @@ export default class ActiveUsersChart extends Chart<ActiveUsersLog> {
|
|||
@autobind
|
||||
public async update(user: User) {
|
||||
const update: Obj = {
|
||||
count: 1
|
||||
users: [user.id]
|
||||
};
|
||||
|
||||
await this.incIfUnique({
|
||||
await this.inc({
|
||||
[Users.isLocalUser(user) ? 'local' : 'remote']: update
|
||||
}, 'users', user.id);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue