diff --git a/package.json b/package.json index b9e31fcf..1313b499 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "del-website", - "version": "5.1.0-Release", + "version": "5.1.1-Release", "description": "Discord Extreme List, Discord's unbiased list! Official source code for the DEL v5 website!", "main": "dist/src/app.js", "directories": { diff --git a/release-info.json b/release-info.json index 5ca6e660..6d3c78ad 100644 --- a/release-info.json +++ b/release-info.json @@ -1,5 +1,5 @@ { - "version": "5.1.0-Release", + "version": "5.1.1-Release", "channel": "Release", "cssVersion": "756d2e7250ac825ed3ea2a5097dfa2df" } diff --git a/src/Util/Services/discord.ts b/src/Util/Services/discord.ts index 571cf526..c0931684 100644 --- a/src/Util/Services/discord.ts +++ b/src/Util/Services/discord.ts @@ -106,33 +106,47 @@ export async function postMetric() { } export async function postWebMetric(type: string) { - switch (type) { - case "bot": - const bots: delBot[] = await global.db + const bots: delBot[] = await global.db .collection("bots") .find() .toArray(); - + + const servers: delServer[] = await global.db + .collection("servers") + .find() + .toArray(); + + const templates: delTemplate[] = await global.db + .collection("templates") + .find() + .toArray(); + + const users: delUser[] = await global.db + .collection("users") + .find() + .toArray(); + + switch (type) { + case "bot": settings.website.dev ? metrics.gauge("del.website.dev.botCount", bots.length) : metrics.gauge("del.website.botCount", bots.length); break; + case "bot_unapproved": + const unapprovedBots = bots.filter( + (b) => !b.status.approved && !b.status.archived + ) + + settings.website.dev + ? metrics.gauge("del.website.dev.botCount.unapproved", unapprovedBots.length) + : metrics.gauge("del.website.botCount.unapproved", unapprovedBots.length); + break; case "server": - const servers: delServer[] = await global.db - .collection("servers") - .find() - .toArray(); - settings.website.dev ? metrics.gauge("del.website.dev.serverCount", servers.length) : metrics.gauge("del.website.serverCount", servers.length); break; case "template": - const templates: delTemplate[] = await global.db - .collection("templates") - .find() - .toArray(); - settings.website.dev ? metrics.gauge( "del.website.dev.templateCount", @@ -141,11 +155,6 @@ export async function postWebMetric(type: string) { : metrics.gauge("del.website.templateCount", templates.length); break; case "user": - const users: delUser[] = await global.db - .collection("users") - .find() - .toArray(); - settings.website.dev ? metrics.gauge("del.website.dev.userCount", users.length) : metrics.gauge("del.website.userCount", users.length); diff --git a/src/app.ts b/src/app.ts index 6c3c3d34..a63f0e7c 100644 --- a/src/app.ts +++ b/src/app.ts @@ -172,6 +172,12 @@ new Promise((resolve, reject) => { await ddosMode.updateCache(); await botStatsUpdate(); await tokenManager.tokenResetAll(); + + await discord.postWebMetric("bot"); + await discord.postWebMetric("bot_unapproved"); + await discord.postWebMetric("server"); + await discord.postWebMetric("template"); + await discord.postWebMetric("user"); setTimeout(async () => { await discord.postMetric();