diff --git a/backend/src/monitor.rs b/backend/src/monitor.rs index ca6d67f64b..57c7f9766d 100644 --- a/backend/src/monitor.rs +++ b/backend/src/monitor.rs @@ -87,11 +87,15 @@ pub async fn monitor_db) { - let queue_counts = sqlx::query!("SELECT tag, count(*) as count FROM queue GROUP BY tag") - .fetch_all(db) - .await - .ok() - .unwrap_or_else(|| vec![]); + let queue_counts = sqlx::query!( + "SELECT tag, count(*) as count FROM queue WHERE + scheduled_for <= now() - ('3 seconds')::interval AND running = false + GROUP BY tag" + ) + .fetch_all(db) + .await + .ok() + .unwrap_or_else(|| vec![]); for q in queue_counts { let count = q.count.unwrap_or(0); let tag = q.tag;