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:
+20
-12
@@ -5,7 +5,7 @@ use std::sync::Arc;
|
|||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct VlmPrompt {
|
pub struct VlmPrompt {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub system_prompt: Option<String>,
|
pub system_prompt: Option<String>,
|
||||||
@@ -17,7 +17,7 @@ pub struct VlmPrompt {
|
|||||||
pub description: String,
|
pub description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct LlmConfig {
|
pub struct LlmConfig {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
pub model: String,
|
pub model: String,
|
||||||
@@ -25,7 +25,7 @@ pub struct LlmConfig {
|
|||||||
pub timeout: u32,
|
pub timeout: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct ProcessorConfig {
|
pub struct ProcessorConfig {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub model_size: Option<String>,
|
pub model_size: Option<String>,
|
||||||
@@ -39,7 +39,7 @@ pub struct ProcessorConfig {
|
|||||||
pub confidence: Option<f32>,
|
pub confidence: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct FilterConfig {
|
pub struct FilterConfig {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub min_confidence: Option<f32>,
|
pub min_confidence: Option<f32>,
|
||||||
@@ -53,7 +53,7 @@ fn default_true() -> bool {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct PathsConfig {
|
pub struct PathsConfig {
|
||||||
#[serde(default = "default_output_dir")]
|
#[serde(default = "default_output_dir")]
|
||||||
pub output_dir: String,
|
pub output_dir: String,
|
||||||
@@ -92,7 +92,7 @@ fn default_ffmpeg_path() -> String {
|
|||||||
.unwrap_or_else(|_| "ffmpeg".to_string())
|
.unwrap_or_else(|_| "ffmpeg".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct FeatureFlags {
|
pub struct FeatureFlags {
|
||||||
#[serde(default = "default_cache_enabled")]
|
#[serde(default = "default_cache_enabled")]
|
||||||
pub cache_enabled: bool,
|
pub cache_enabled: bool,
|
||||||
@@ -110,7 +110,7 @@ fn default_cache_enabled() -> bool {
|
|||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct ConcurrencyConfig {
|
pub struct ConcurrencyConfig {
|
||||||
#[serde(default = "default_max_concurrent_jobs")]
|
#[serde(default = "default_max_concurrent_jobs")]
|
||||||
pub max_concurrent_jobs: u32,
|
pub max_concurrent_jobs: u32,
|
||||||
@@ -150,7 +150,7 @@ fn default_processor_timeout_secs() -> u32 {
|
|||||||
.unwrap_or(3600)
|
.unwrap_or(3600)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct AdminSettings {
|
pub struct AdminSettings {
|
||||||
#[serde(default = "default_session_timeout")]
|
#[serde(default = "default_session_timeout")]
|
||||||
pub session_timeout: u32,
|
pub session_timeout: u32,
|
||||||
@@ -162,7 +162,7 @@ pub struct AdminSettings {
|
|||||||
pub system_stats_refresh_sec: u32,
|
pub system_stats_refresh_sec: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct FaceFilterDefaults {
|
pub struct FaceFilterDefaults {
|
||||||
#[serde(default = "default_min_confidence")]
|
#[serde(default = "default_min_confidence")]
|
||||||
pub min_confidence: f64,
|
pub min_confidence: f64,
|
||||||
@@ -195,7 +195,7 @@ fn default_system_stats_refresh_sec() -> u32 {
|
|||||||
.unwrap_or(5)
|
.unwrap_or(5)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct ServerConfig {
|
pub struct ServerConfig {
|
||||||
#[serde(default = "default_server_port")]
|
#[serde(default = "default_server_port")]
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
@@ -229,25 +229,33 @@ fn default_storage_root() -> String {
|
|||||||
.unwrap_or_else(|_| "/Users/accusys/momentry/var/sftpgo/data".to_string())
|
.unwrap_or_else(|_| "/Users/accusys/momentry/var/sftpgo/data".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct AdminConfig {
|
pub struct AdminConfig {
|
||||||
pub version: String,
|
pub version: String,
|
||||||
|
#[serde(default)]
|
||||||
pub updated_at: String,
|
pub updated_at: String,
|
||||||
|
#[serde(default)]
|
||||||
pub updated_by: String,
|
pub updated_by: String,
|
||||||
pub vlm_prompts: HashMap<String, VlmPrompt>,
|
pub vlm_prompts: HashMap<String, VlmPrompt>,
|
||||||
pub llm_config: HashMap<String, LlmConfig>,
|
pub llm_config: HashMap<String, LlmConfig>,
|
||||||
pub processor_config: HashMap<String, ProcessorConfig>,
|
pub processor_config: HashMap<String, ProcessorConfig>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub filter_config: HashMap<String, FilterConfig>,
|
pub filter_config: HashMap<String, FilterConfig>,
|
||||||
|
#[serde(default)]
|
||||||
pub face_filter_defaults: FaceFilterDefaults,
|
pub face_filter_defaults: FaceFilterDefaults,
|
||||||
|
#[serde(default)]
|
||||||
pub paths: PathsConfig,
|
pub paths: PathsConfig,
|
||||||
|
#[serde(default)]
|
||||||
pub concurrency: ConcurrencyConfig,
|
pub concurrency: ConcurrencyConfig,
|
||||||
|
#[serde(default)]
|
||||||
pub feature_flags: FeatureFlags,
|
pub feature_flags: FeatureFlags,
|
||||||
|
#[serde(default)]
|
||||||
pub server: ServerConfig,
|
pub server: ServerConfig,
|
||||||
|
#[serde(default)]
|
||||||
pub admin_settings: AdminSettings,
|
pub admin_settings: AdminSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
pub struct PartialAdminConfig {
|
pub struct PartialAdminConfig {
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub vlm_prompts: Option<HashMap<String, VlmPrompt>>,
|
pub vlm_prompts: Option<HashMap<String, VlmPrompt>>,
|
||||||
|
|||||||
@@ -3390,7 +3390,20 @@ impl PostgresDb {
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let table = schema::table_name("processor_results");
|
let table = schema::table_name("processor_results");
|
||||||
let s = format!("{:?}", status).to_lowercase();
|
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(&s)
|
||||||
.bind(result_id)
|
.bind(result_id)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
|
|||||||
Reference in New Issue
Block a user