Add requests counter

This commit is contained in:
2022-02-16 19:04:07 +03:00
parent ae38fd9b9a
commit ce8af5a877

View File

@@ -1,6 +1,7 @@
export default class UsersCounter { export default class UsersCounter {
static bots: {[key: string]: Set<number>} = {}; static bots: {[key: string]: Set<number>} = {};
static allUsers: Set<number> = new Set(); static allUsers: Set<number> = new Set();
static requests = 0;
static take(userId: number, bot: string) { static take(userId: number, bot: string) {
const isExists = this.bots[bot]; const isExists = this.bots[bot];
@@ -11,6 +12,7 @@ export default class UsersCounter {
this.bots[bot].add(userId); this.bots[bot].add(userId);
this.allUsers.add(userId); this.allUsers.add(userId);
this.requests++;
} }
static getAllUsersCount(): number { static getAllUsersCount(): number {
@@ -29,6 +31,7 @@ export default class UsersCounter {
const lines = []; const lines = [];
lines.push(`all_users_count ${this.getAllUsersCount()}`); lines.push(`all_users_count ${this.getAllUsersCount()}`);
lines.push(`requests_count ${this.requests}`);
const usersByBots = this.getUsersByBots(); const usersByBots = this.getUsersByBots();