Skip to content

Commit

Permalink
disable some account stats
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Jan 25, 2025
1 parent 2fe0b9d commit 7b5bf5e
Showing 1 changed file with 84 additions and 85 deletions.
169 changes: 84 additions & 85 deletions src/generator/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
SKINS_UNIQUE,
Stats
} from "./Stats";
import { IPoint } from "influx";
import { DelayInfo } from "../typings/DelayInfo";
import { Capes } from "../util/Capes";
import { requestShutdown } from "../index";
Expand Down Expand Up @@ -260,91 +259,91 @@ export class Generator {
let usableAccounts = usableAccountDocs.length;
this.usableAccounts = usableAccounts;

let accountsPerProxy: { [k: string]: number } = {};
for (let acc of usableAccountDocs) {
let key = acc.requestServer;
if (!key || key === "null") {
key = "default";
}
accountsPerProxy[key] = (accountsPerProxy[key] || 0) + 1;
}

const accountTypes = await Account.aggregate([
{
"$match": {
requestServer: {$in: ["default", ...await this.getRequestServers()]}
}
}, {
"$group":
{
_id: "$accountType",
count: {$sum: 1}
}
}
]).exec().then((res: any[]) => {
let counts: { [type: string]: number; } = {};
res.forEach(e => {
counts[e["_id"]] = e["count"];
})
return counts;
});

try {
const metrics = container.get<IMetricsProvider>(CoreTypes.MetricsProvider);
await metrics.getMetrics().influx.writePoints([
{
measurement: 'accounts',
tags: {
server: HOSTNAME
},
fields: {
totalServer: serverAccounts,
useable: usableAccounts
}
}
], {
database: 'mineskin',
precision: 's'
})
for (let p in accountsPerProxy) {
await metrics.getMetrics().influx.writePoints([
{
measurement: 'proxy_accounts',
tags: {
server: HOSTNAME,
proxy: p
},
fields: {
useable: accountsPerProxy[p]
}
}
], {
database: 'mineskin',
precision: 's'
})
}
// let accountsPerProxy: { [k: string]: number } = {};
// for (let acc of usableAccountDocs) {
// let key = acc.requestServer;
// if (!key || key === "null") {
// key = "default";
// }
// accountsPerProxy[key] = (accountsPerProxy[key] || 0) + 1;
// }

let accountsPerTypePoints: IPoint[] = [];
for (let accountType in accountTypes) {
accountsPerTypePoints.push({
measurement: 'account_types',
tags: {
server: HOSTNAME,
type: accountType
},
fields: {
count: accountTypes[accountType]
}
})
}
await metrics.getMetrics().influx.writePoints(accountsPerTypePoints, {
database: 'mineskin',
precision: 's'
})
} catch (e) {
console.warn(e);
Sentry.captureException(e);
}
// const accountTypes = await Account.aggregate([
// {
// "$match": {
// requestServer: {$in: ["default", ...await this.getRequestServers()]}
// }
// }, {
// "$group":
// {
// _id: "$accountType",
// count: {$sum: 1}
// }
// }
// ]).exec().then((res: any[]) => {
// let counts: { [type: string]: number; } = {};
// res.forEach(e => {
// counts[e["_id"]] = e["count"];
// })
// return counts;
// });

// try {
// const metrics = container.get<IMetricsProvider>(CoreTypes.MetricsProvider);
// await metrics.getMetrics().influx.writePoints([
// {
// measurement: 'accounts',
// tags: {
// server: HOSTNAME
// },
// fields: {
// totalServer: serverAccounts,
// useable: usableAccounts
// }
// }
// ], {
// database: 'mineskin',
// precision: 's'
// })
// for (let p in accountsPerProxy) {
// await metrics.getMetrics().influx.writePoints([
// {
// measurement: 'proxy_accounts',
// tags: {
// server: HOSTNAME,
// proxy: p
// },
// fields: {
// useable: accountsPerProxy[p]
// }
// }
// ], {
// database: 'mineskin',
// precision: 's'
// })
// }
//
// let accountsPerTypePoints: IPoint[] = [];
// for (let accountType in accountTypes) {
// accountsPerTypePoints.push({
// measurement: 'account_types',
// tags: {
// server: HOSTNAME,
// type: accountType
// },
// fields: {
// count: accountTypes[accountType]
// }
// })
// }
// await metrics.getMetrics().influx.writePoints(accountsPerTypePoints, {
// database: 'mineskin',
// precision: 's'
// })
// } catch (e) {
// console.warn(e);
// Sentry.captureException(e);
// }

console.log(debug(`Took ${ (Date.now() - start) }ms for account stats`));
}
Expand Down

0 comments on commit 7b5bf5e

Please sign in to comment.