fix: pass face_settings to create_monitor_job in register and process endpoints
- files.rs: register_file now converts FaceSettings to json and passes to create_monitor_job - processing.rs: ProcessRequest now includes face_settings field - processing.rs: trigger_processing now passes face_settings to create_monitor_job and updates existing jobs - docs: updated API examples to use correct endpoints (/api/v1/files/register and /api/v1/files/:uuid/process)
This commit is contained in:
+31
-1
@@ -108,10 +108,17 @@ struct WatcherAutoRegisterToggleResponse {
|
||||
message: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct FaceSettings {
|
||||
min_confidence: Option<f64>,
|
||||
min_size: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct ProcessRequest {
|
||||
rules: Option<Vec<String>>,
|
||||
processors: Option<Vec<String>>,
|
||||
face_settings: Option<FaceSettings>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -260,6 +267,14 @@ async fn trigger_processing(
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
|
||||
// Convert face_settings to serde_json::Value for create_monitor_job
|
||||
let face_settings_json = req.face_settings.as_ref().map(|fs| {
|
||||
serde_json::json!({
|
||||
"min_confidence": fs.min_confidence.unwrap_or(0.75),
|
||||
"min_size": fs.min_size.unwrap_or(64)
|
||||
})
|
||||
});
|
||||
|
||||
if let Some(job_id) = existing_id {
|
||||
// Clean up stale processor_results from previous runs
|
||||
// Old entries with status='running' from a dead worker session
|
||||
@@ -278,10 +293,25 @@ async fn trigger_processing(
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
tracing::info!("[TRIGGER] Cleaned processor_results for job {}", job_id);
|
||||
|
||||
// Update existing job with new face_settings if provided
|
||||
if let Some(ref fs_json) = face_settings_json {
|
||||
sqlx::query(&format!(
|
||||
"UPDATE {monitor_jobs_table} SET face_settings = $1::jsonb WHERE id = $2"
|
||||
))
|
||||
.bind(&fs_json.to_string())
|
||||
.bind(job_id)
|
||||
.execute(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("[TRIGGER] Failed to update face_settings for job {}: {}", job_id, e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
}
|
||||
} else {
|
||||
state
|
||||
.db
|
||||
.create_monitor_job(&file_uuid, Some(&file_path), None)
|
||||
.create_monitor_job(&file_uuid, Some(&file_path), face_settings_json.as_ref())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!(
|
||||
|
||||
Reference in New Issue
Block a user