From 10b6b1dc04cb2b2d4ec5ceb26a5dbd2ac7bd1394 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 14 Nov 2024 11:03:26 +0100 Subject: [PATCH] fix: add queue_couts api --- backend/windmill-api/openapi.yaml | 17 +++++++++++++++++ backend/windmill-api/src/workers.rs | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index a85619dde7..97d98d3d6b 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -8188,6 +8188,23 @@ paths: - id - values + /workers/queue_counts: + get: + summary: get counts of jobs waiting for an executor per tag + operationId: getCountsOfJobsWaitingPerTag + tags: + - worker + responses: + "200": + description: queue counts + content: + application/json: + schema: + type: object + additionalProperties: + type: integer + + /configs/list_worker_groups: get: summary: list worker groups diff --git a/backend/windmill-api/src/workers.rs b/backend/windmill-api/src/workers.rs index 2f8439bf24..6eeeb17bac 100644 --- a/backend/windmill-api/src/workers.rs +++ b/backend/windmill-api/src/workers.rs @@ -36,6 +36,7 @@ pub fn global_service() -> Router { ) .route("/get_default_tags", get(get_default_tags)) .route("/queue_metrics", get(get_queue_metrics)) + .route("/queue_counts", get(get_queue_counts)) } #[derive(FromRow, Serialize, Deserialize)] @@ -176,3 +177,12 @@ async fn get_queue_metrics( Ok(Json(queue_metrics)) } + +async fn get_queue_counts( + authed: ApiAuthed, + Extension(db): Extension, +) -> JsonResult> { + require_super_admin(&db, &authed.email).await?; + let queue_counts = windmill_common::queue::get_queue_counts(&db).await; + Ok(Json(queue_counts)) +} \ No newline at end of file