backend: add /jobs_u/queue/poll API

This commit is contained in:
Abel Lucas
2025-01-24 09:53:47 +01:00
parent 4a3f7ce0dd
commit 0caa347d92
2 changed files with 41 additions and 0 deletions
@@ -0,0 +1,23 @@
{
"db_name": "PostgreSQL",
"query": "SELECT id FROM v2_job_queue WHERE id = ANY($1) AND workspace_id = $2",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Uuid"
}
],
"parameters": {
"Left": [
"UuidArray",
"Text"
]
},
"nullable": [
false
]
},
"hash": "52a461456416560066e7c77a73e17793866b778b743274faea90965b1ff8ab92"
}
+18
View File
@@ -206,6 +206,7 @@ pub fn workspaced_service() -> Router {
.route("/queue/list", get(list_queue_jobs))
.route("/queue/count", get(count_queue_jobs))
.route("/queue/list_filtered_uuids", get(list_filtered_uuids))
.route("/queue/poll", post(poll))
.route("/queue/cancel_selection", post(cancel_selection))
.route("/completed/count", get(count_completed_jobs))
.route("/completed/count_jobs", get(count_completed_jobs_detail))
@@ -1581,6 +1582,23 @@ async fn cancel_selection(
cancel_jobs(jobs_to_cancel, &db, authed.username.as_str(), w_id.as_str()).await
}
async fn poll(
_authed: ApiAuthed,
Extension(db): Extension<DB>,
Path(w_id): Path<String>,
Json(jobs): Json<Vec<Uuid>>,
) -> JsonResult<Vec<Uuid>> {
sqlx::query_scalar!(
"SELECT id FROM v2_job_queue WHERE id = ANY($1) AND workspace_id = $2",
&jobs,
&w_id
)
.fetch_all(&db)
.await
.map(Json)
.map_err(Into::into)
}
async fn list_filtered_uuids(
authed: ApiAuthed,
Extension(db): Extension<DB>,