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:
Accusys
2026-08-08 22:16:06 +08:00
parent d5c7fd91d9
commit 658f509500
3 changed files with 71 additions and 7 deletions
+8 -1
View File
@@ -805,6 +805,13 @@ async fn register_file(
{
let auto_uuid = resp.file_uuid.clone();
let auto_state = state.clone();
// 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)
})
});
tokio::spawn(async move {
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
let video_path: Option<String> = sqlx::query_scalar(&format!(
@@ -818,7 +825,7 @@ async fn register_file(
.flatten();
if let Some(ref vp) = video_path {
if let Ok(job) = auto_state.db.create_monitor_job(&auto_uuid, Some(vp), None).await {
if let Ok(job) = auto_state.db.create_monitor_job(&auto_uuid, Some(vp), face_settings_json.as_ref()).await {
tracing::info!("[AUTO-PIPELINE] Job {} created for {}", job.id, auto_uuid);
let all_procs: Vec<&str> =
vec!["cut", "asr", "asrx", "ocr", "face", "pose", "appearance"];
+31 -1
View File
@@ -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!(