mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 00:03:07 +00:00
fix: fix delete completed job
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE v2_job_completed c SET\n result = NULL,\n deleted = TRUE\n FROM v2_job j\n WHERE c.id = $1\n AND j.id = c.id\n AND c.workspace_id = $2\n AND ($3::TEXT[] IS NULL OR tag = ANY($3))\n RETURNING c.id\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Uuid"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Text",
|
||||
"TextArray"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "51ef2ee9dc252f7accc41b89d13a2aa1e4c11d4860894e9e661b6ee3bccd8522"
|
||||
}
|
||||
@@ -5929,6 +5929,7 @@ async fn get_completed_job_result_maybe(
|
||||
async fn delete_completed_job<'a>(
|
||||
authed: ApiAuthed,
|
||||
Extension(user_db): Extension<UserDB>,
|
||||
Extension(db): Extension<DB>,
|
||||
Path((w_id, id)): Path<(String, Uuid)>,
|
||||
) -> error::Result<Response> {
|
||||
check_scopes(&authed, || format!("jobs:deletejob"))?;
|
||||
@@ -5937,9 +5938,8 @@ async fn delete_completed_job<'a>(
|
||||
|
||||
require_admin(authed.is_admin, &authed.username)?;
|
||||
let tags = get_scope_tags(&authed);
|
||||
let job_o = sqlx::query_as::<_, CompletedJob>(
|
||||
"WITH mark_as_deleted AS (
|
||||
UPDATE v2_job_completed c SET
|
||||
let job_o = sqlx::query_scalar!(
|
||||
"UPDATE v2_job_completed c SET
|
||||
result = NULL,
|
||||
deleted = TRUE
|
||||
FROM v2_job j
|
||||
@@ -5948,15 +5948,15 @@ async fn delete_completed_job<'a>(
|
||||
AND c.workspace_id = $2
|
||||
AND ($3::TEXT[] IS NULL OR tag = ANY($3))
|
||||
RETURNING c.id
|
||||
) SELECT * FROM v2_as_completed_job WHERE id = (SELECT id FROM mark_as_deleted)",
|
||||
",
|
||||
id,
|
||||
&w_id,
|
||||
tags.as_ref().map(|v| v.as_slice()) as Option<&[&str]>,
|
||||
)
|
||||
.bind(id)
|
||||
.bind(&w_id)
|
||||
.bind(tags.as_ref().map(|v| v.as_slice()))
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
|
||||
let cj = not_found_if_none(job_o, "Completed Job", id.to_string())?;
|
||||
not_found_if_none(job_o, "Completed Job", id.to_string())?;
|
||||
|
||||
sqlx::query!("UPDATE v2_job SET args = NULL WHERE id = $1", id)
|
||||
.execute(&mut *tx)
|
||||
@@ -5977,9 +5977,5 @@ async fn delete_completed_job<'a>(
|
||||
.await?;
|
||||
|
||||
tx.commit().await?;
|
||||
|
||||
let cj = format_completed_job_result(cj);
|
||||
|
||||
let response = Json(cj).into_response();
|
||||
Ok(response)
|
||||
return get_completed_job(OptAuthed(Some(authed)), Extension(db), Path((w_id, id))).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user