From 26748d4b2ea63a07dc0dbc48ca3149122b192e0e Mon Sep 17 00:00:00 2001 From: Cairo Date: Thu, 16 Jul 2020 22:46:17 +1200 Subject: [PATCH 1/5] Add unapproved bot web metric --- src/Util/Services/discord.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Util/Services/discord.ts b/src/Util/Services/discord.ts index 571cf526..b23d948e 100644 --- a/src/Util/Services/discord.ts +++ b/src/Util/Services/discord.ts @@ -117,6 +117,20 @@ export async function postWebMetric(type: string) { ? metrics.gauge("del.website.dev.botCount", bots.length) : metrics.gauge("del.website.botCount", bots.length); break; + case "bot_unapproved": + const bots: delBot[] = await global.db + .collection("bots") + .find() + .toArray(); + + 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") From f4a4eb7fd85e5b9368e3f4026b2141f5c5486d2e Mon Sep 17 00:00:00 2001 From: Cairo Date: Thu, 16 Jul 2020 22:46:55 +1200 Subject: [PATCH 2/5] Make web metrics get triggered on start --- src/app.ts | 6 ++++++ 1 file changed, 6 insertions(+) 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(); From 4598461f34c1137ed39e5d1278f6354dbd77517d Mon Sep 17 00:00:00 2001 From: Cairo Date: Thu, 16 Jul 2020 22:47:00 +1200 Subject: [PATCH 3/5] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": { From 53b269584985037e0bf98bd727872bc3ba74e231 Mon Sep 17 00:00:00 2001 From: Cairo Date: Thu, 16 Jul 2020 22:47:05 +1200 Subject: [PATCH 4/5] Update release-info.json --- release-info.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" } From eddf7e09ac2ca2dfa7f3cfd941bc7aebe298a22c Mon Sep 17 00:00:00 2001 From: Cairo Date: Thu, 16 Jul 2020 22:52:28 +1200 Subject: [PATCH 5/5] Update discord.ts --- src/Util/Services/discord.ts | 43 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/Util/Services/discord.ts b/src/Util/Services/discord.ts index b23d948e..c0931684 100644 --- a/src/Util/Services/discord.ts +++ b/src/Util/Services/discord.ts @@ -106,23 +106,33 @@ 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 bots: delBot[] = await global.db - .collection("bots") - .find() - .toArray(); - const unapprovedBots = bots.filter( (b) => !b.status.approved && !b.status.archived ) @@ -132,21 +142,11 @@ export async function postWebMetric(type: string) { : 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", @@ -155,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);