From 685eb5d471433eae28bdd464ebf8d66a5c6399bd Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 12 Oct 2024 13:39:59 +0200 Subject: [PATCH] support skip_update --- backend/windmill-api/src/jobs.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/backend/windmill-api/src/jobs.rs b/backend/windmill-api/src/jobs.rs index 89d5e70115..c79d4bfe2c 100644 --- a/backend/windmill-api/src/jobs.rs +++ b/backend/windmill-api/src/jobs.rs @@ -3049,6 +3049,10 @@ pub async fn run_script_by_path_inner( Ok((StatusCode::CREATED, uuid.to_string())) } +#[derive(Deserialize)] +pub struct WorkflowAsCodeQuery { + pub skip_update: Option, +} pub async fn run_workflow_as_code( authed: ApiAuthed, Extension(db): Extension, @@ -3056,6 +3060,7 @@ pub async fn run_workflow_as_code( Extension(rsmq): Extension>, Path((w_id, job_id, entrypoint)): Path<(String, Uuid, String)>, Query(run_query): Query, + Query(wkflow_query): Query, Json(task): Json, ) -> error::Result<(StatusCode, String)> { #[cfg(feature = "enterprise")] @@ -3135,13 +3140,18 @@ pub async fn run_workflow_as_code( Some(&authed.clone().into()), ) .await?; - sqlx::query!( - "UPDATE queue SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($4::text))) WHERE id = $2 AND workspace_id = $3", - uuid.to_string(), - job_id, - w_id, - entrypoint - ).execute(&mut tx).await?; + if !wkflow_query.skip_update.unwrap_or(false) { + sqlx::query!( + "UPDATE queue SET flow_status = jsonb_set(COALESCE(flow_status, '{}'::jsonb), array[$1], jsonb_set(jsonb_set('{}'::jsonb, '{scheduled_for}', to_jsonb(now()::text)), '{name}', to_jsonb($4::text))) WHERE id = $2 AND workspace_id = $3", + uuid.to_string(), + job_id, + w_id, + entrypoint + ).execute(&mut tx).await?; + } else { + tracing::info!("Skipping update of flow status for job {job_id} in workspace {w_id}"); + } + tx.commit().await?; Ok((StatusCode::CREATED, uuid.to_string())) }