fix: processor status timestamps and admin config defaults

** Problem 1: started_at not set
- update_processor_result() ignored started_at/completed_at parameters
- Only updated 'status' field, leaving timestamps as None
- Caused false 'running' state detection

** Problem 2: AdminConfig missing fields
- admin_config.json missing required fields (updated_at, paths, etc.)
- JSON parsing failed, caused panic on worker startup
- Lazy instance poisoned, all processors failed

** Fix:
1. update_processor_result now sets timestamps automatically:
   - Running -> started_at = CURRENT_TIMESTAMP
   - Completed/Failed -> completed_at = CURRENT_TIMESTAMP

2. Added #[serde(default)] to all AdminConfig fields
   - Allows partial config files
   - Missing fields get default values

** Impact:
- Processor status now accurately tracked
- Worker can start with minimal config
- UI 'Deep Scan' deadlock resolved
This commit is contained in:
Accusys
2026-09-18 05:00:59 +08:00
parent a8edc43a3f
commit 3aaaf36ff6
2 changed files with 34 additions and 13 deletions
+14 -1
View File
@@ -3390,7 +3390,20 @@ impl PostgresDb {
) -> Result<()> {
let table = schema::table_name("processor_results");
let s = format!("{:?}", status).to_lowercase();
sqlx::query(&format!("UPDATE {} SET status = $1 WHERE id = $2", table))
let query = match status {
crate::core::db::ProcessorJobStatus::Running => {
format!("UPDATE {} SET status = $1, started_at = CURRENT_TIMESTAMP WHERE id = $2", table)
}
crate::core::db::ProcessorJobStatus::Completed | crate::core::db::ProcessorJobStatus::Failed => {
format!("UPDATE {} SET status = $1, completed_at = CURRENT_TIMESTAMP WHERE id = $2", table)
}
_ => {
format!("UPDATE {} SET status = $1 WHERE id = $2", table)
}
};
sqlx::query(&query)
.bind(&s)
.bind(result_id)
.execute(&self.pool)