diff --git a/src/api/scan.rs b/src/api/scan.rs index e2f6ca9..5ed68b9 100644 --- a/src/api/scan.rs +++ b/src/api/scan.rs @@ -590,11 +590,23 @@ async fn get_ingestion_status( let strangers = strangers; + // Check if job is completed - if so, all ingestion steps are considered done + let mj_table = schema::table_name("monitor_jobs"); + let job_completed: bool = sqlx::query_scalar::<_, String>(&format!( + "SELECT status FROM {mj_table} WHERE uuid = $1" + )) + .bind(&file_uuid) + .fetch_optional(pool) + .await + .unwrap_or(None) + .map(|s| s == "completed") + .unwrap_or(false); + macro_rules! step { ($name:expr, $done:expr, $detail:expr) => { IngestionStep { name: $name.into(), - status: if $done { "done" } else { "pending" }.into(), + status: if $done || job_completed { "done" } else { "pending" }.into(), detail: $detail, } };