Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(nuq): only tally queued and active jobs in getMetrics

Gergő Móriczdd5f957db74f
diff --git a/apps/api/src/services/worker/nuq.ts b/apps/api/src/services/worker/nuq.ts
index 08fff6647..2d85481f0 100644
--- a/apps/api/src/services/worker/nuq.ts
+++ b/apps/api/src/services/worker/nuq.ts
@@ -1243,9 +1243,13 @@ class NuQ<JobData = any, JobReturnValue = any> {
// === Metrics
public async getMetrics(): Promise<string> {
const start = Date.now();
+ // swapped to slim version for performance reasons - mogery
+ // const result = await nuqPool.query(`
+ // SELECT status::text, COUNT(id) as count FROM ${this.queueName} GROUP BY status
+ // ${this.options.backlog ? `UNION ALL SELECT 'backlog'::text as status, COUNT(id) as count FROM ${this.queueName}_backlog` : ""}
+ // `);
const result = await nuqPool.query(`
- SELECT status::text, COUNT(id) as count FROM ${this.queueName} GROUP BY status
- ${this.options.backlog ? `UNION ALL SELECT 'backlog'::text as status, COUNT(id) as count FROM ${this.queueName}_backlog` : ""}
+ SELECT status::text, COUNT(id) as count FROM ${this.queueName} WHERE status IN ('queued', 'active') GROUP BY status
`);
logger.info("nuqGetMetrics metrics", {
module: "nuq/metrics",