From c7dfd0ebc416c9861d8c5f8d6e3399990095fb71 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 10 Oct 2022 14:41:59 +0200 Subject: [PATCH] fix suspend count for early message + delete resume_job --- backend/sqlx-data.json | 12 ++++++++++++ backend/src/worker_flow.rs | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/backend/sqlx-data.json b/backend/sqlx-data.json index b342ac66d9..dfddd71bba 100644 --- a/backend/sqlx-data.json +++ b/backend/sqlx-data.json @@ -3415,6 +3415,18 @@ }, "query": "SELECT workspace.* FROM workspace, usr WHERE usr.workspace_id = workspace.id AND usr.email = $1 AND deleted = false" }, + "f9136bc01bdb7d0e644efff25b7cc8035194df0452bc8b2005fe1fa44de19db4": { + "describe": { + "columns": [], + "nullable": [], + "parameters": { + "Left": [ + "Uuid" + ] + } + }, + "query": "DELETE FROM resume_job WHERE job = $1" + }, "f98046a2ee4ac10d9e507c033391dfb0c704dcd513d8b1e5564def4e85f9e80b": { "describe": { "columns": [], diff --git a/backend/src/worker_flow.rs b/backend/src/worker_flow.rs index 026e4c0fcc..f8e9bcb778 100644 --- a/backend/src/worker_flow.rs +++ b/backend/src/worker_flow.rs @@ -663,6 +663,10 @@ async fn push_next_flow_job( .context("previous job result")?; } + sqlx::query!("DELETE FROM resume_job WHERE job = $1", last) + .execute(&mut tx) + .await?; + /* continue on and run this job! */ tx.commit().await?; @@ -680,7 +684,7 @@ async fn push_next_flow_job( ", ) .bind(json!(FlowStatusModule::WaitingForEvents { count, job: last })) - .bind(count as i32) + .bind((count - resume_messages.len() as u16) as i32) .bind(30 * MINUTES) .bind(flow_job.id) .execute(&mut tx)