Fix job status transitions
Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
@@ -448,6 +448,23 @@ async fn deliver_one(
|
||||
MessageStatus::Processed,
|
||||
)
|
||||
.await;
|
||||
// Also mark job as Finished so the flow can progress (ignore invalid transitions)
|
||||
let _ = service_poll
|
||||
.update_job_status_unchecked(
|
||||
context_id, caller_id, job_id, JobStatus::Finished,
|
||||
)
|
||||
.await;
|
||||
let _ = service_poll
|
||||
.append_message_logs(
|
||||
context_id,
|
||||
caller_id,
|
||||
id,
|
||||
vec![format!(
|
||||
"Updated job {} status to Finished (sync)", job_id
|
||||
)],
|
||||
)
|
||||
.await;
|
||||
// Existing log about storing result
|
||||
let _ = service_poll
|
||||
.append_message_logs(
|
||||
context_id,
|
||||
@@ -481,6 +498,23 @@ async fn deliver_one(
|
||||
MessageStatus::Processed,
|
||||
)
|
||||
.await;
|
||||
// Also mark job as Error so the flow can handle failure (ignore invalid transitions)
|
||||
let _ = service_poll
|
||||
.update_job_status_unchecked(
|
||||
context_id, caller_id, job_id, JobStatus::Error,
|
||||
)
|
||||
.await;
|
||||
let _ = service_poll
|
||||
.append_message_logs(
|
||||
context_id,
|
||||
caller_id,
|
||||
id,
|
||||
vec![format!(
|
||||
"Updated job {} status to Error (sync)", job_id
|
||||
)],
|
||||
)
|
||||
.await;
|
||||
// Existing log about storing result
|
||||
let _ = service_poll
|
||||
.append_message_logs(
|
||||
context_id,
|
||||
@@ -516,6 +550,23 @@ async fn deliver_one(
|
||||
MessageStatus::Processed,
|
||||
)
|
||||
.await;
|
||||
// Also mark job as Finished so the flow can progress (ignore invalid transitions)
|
||||
let _ = service_poll
|
||||
.update_job_status_unchecked(
|
||||
context_id, caller_id, job_id, JobStatus::Finished,
|
||||
)
|
||||
.await;
|
||||
let _ = service_poll
|
||||
.append_message_logs(
|
||||
context_id,
|
||||
caller_id,
|
||||
id,
|
||||
vec![format!(
|
||||
"Updated job {} status to Finished (sync)", job_id
|
||||
)],
|
||||
)
|
||||
.await;
|
||||
// Existing log about storing result
|
||||
let _ = service_poll
|
||||
.append_message_logs(
|
||||
context_id,
|
||||
|
@@ -672,10 +672,10 @@ impl AppService {
|
||||
let allowed = match current {
|
||||
JobStatus::Dispatched => matches!(
|
||||
new_status,
|
||||
JobStatus::WaitingForPrerequisites | JobStatus::Started | JobStatus::Error
|
||||
JobStatus::WaitingForPrerequisites | JobStatus::Started | JobStatus::Finished | JobStatus::Error
|
||||
),
|
||||
JobStatus::WaitingForPrerequisites => {
|
||||
matches!(new_status, JobStatus::Started | JobStatus::Error)
|
||||
matches!(new_status, JobStatus::Started | JobStatus::Finished | JobStatus::Error)
|
||||
}
|
||||
JobStatus::Started => matches!(new_status, JobStatus::Finished | JobStatus::Error),
|
||||
JobStatus::Finished | JobStatus::Error => false,
|
||||
@@ -714,10 +714,10 @@ impl AppService {
|
||||
let allowed = match current {
|
||||
JobStatus::Dispatched => matches!(
|
||||
new_status,
|
||||
JobStatus::WaitingForPrerequisites | JobStatus::Started | JobStatus::Error
|
||||
JobStatus::WaitingForPrerequisites | JobStatus::Started | JobStatus::Finished | JobStatus::Error
|
||||
),
|
||||
JobStatus::WaitingForPrerequisites => {
|
||||
matches!(new_status, JobStatus::Started | JobStatus::Error)
|
||||
matches!(new_status, JobStatus::Started | JobStatus::Finished | JobStatus::Error)
|
||||
}
|
||||
JobStatus::Started => matches!(new_status, JobStatus::Finished | JobStatus::Error),
|
||||
JobStatus::Finished | JobStatus::Error => false,
|
||||
|
Reference in New Issue
Block a user