From c13c19c0809aec1333830339b71b84044b47da21 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Thu, 29 Oct 2020 01:45:01 -0400 Subject: [PATCH] more fixes --- src/class/Queue.ts | 20 ++++++++++++++++++++ src/commands/stats.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/src/class/Queue.ts b/src/class/Queue.ts index 5be214a..daf587f 100644 --- a/src/class/Queue.ts +++ b/src/class/Queue.ts @@ -15,6 +15,26 @@ export default class Queue { this.setProcessors(); } + public async jobCounts() { + const data = { + waiting: 0, + active: 0, + completed: 0, + failed: 0, + delayed: 0, + }; + for (const entry of Object.entries(this.queues)) { + // eslint-disable-next-line no-await-in-loop + const counts = await entry[1].getJobCounts(); + data.waiting += counts.waiting; + data.active += counts.active; + data.completed += counts.completed; + data.failed += counts.failed; + data.delayed += counts.delayed; + } + return data; + } + protected listeners() { this.queues.score.on('active', (job) => { this.client.util.signale.pending(`${job.id} has become active.`); diff --git a/src/commands/stats.ts b/src/commands/stats.ts index 6454ba3..72f59ea 100644 --- a/src/commands/stats.ts +++ b/src/commands/stats.ts @@ -26,6 +26,7 @@ export default class Stats extends Command { embed.addField('Commands Executed', `${commands.value}`, true); embed.addField('HTTP Requests Served', `${requests.value}`, true); embed.addField('Pages Sent', `${pages.value}`, true); + embed.addField('Jobs Processed', `${(await this.client.queue.jobCounts()).completed}`, true); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); return message.channel.createMessage({ embed });