fix: update trigger_processing face defaults to Apple Vision (0.5/1)
Hard-coded 0.75/64 in trigger_processing API was overriding the new Apple Vision defaults when re-triggering processing. Now uses 0.5/1 consistently.
This commit is contained in:
+46
-21
@@ -209,20 +209,27 @@ async fn trigger_processing(
|
||||
Json(req): Json<ProcessRequest>,
|
||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
let videos_table = schema::table_name("videos");
|
||||
let row: Option<(String, String, String, Option<String>, String, Option<String>)> =
|
||||
sqlx::query_as(&format!(
|
||||
"SELECT file_uuid, file_path, file_name, file_type, COALESCE(processing_status::text, 'REGISTERED'), content_hash FROM {} WHERE file_uuid = $1",
|
||||
videos_table
|
||||
))
|
||||
.bind(&uuid)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("DB error: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
let row: Option<(
|
||||
String,
|
||||
String,
|
||||
String,
|
||||
Option<String>,
|
||||
String,
|
||||
Option<String>,
|
||||
Option<serde_json::Value>,
|
||||
)> = sqlx::query_as(&format!(
|
||||
"SELECT file_uuid, file_path, file_name, file_type, COALESCE(processing_status::text, 'REGISTERED'), content_hash, face_filter FROM {} WHERE file_uuid = $1",
|
||||
videos_table
|
||||
))
|
||||
.bind(&uuid)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("DB error: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
|
||||
let (file_uuid, file_path, file_name, file_type, processing_status, content_hash) =
|
||||
let (file_uuid, file_path, file_name, file_type, processing_status, content_hash, face_filter) =
|
||||
row.ok_or(StatusCode::NOT_FOUND)?;
|
||||
|
||||
if processing_status == "PROCESSING" || processing_status == "QUEUED" {
|
||||
@@ -267,13 +274,27 @@ 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)
|
||||
})
|
||||
});
|
||||
// Convert face_settings to serde_json::Value for create_monitor_job.
|
||||
// Priority: explicit request settings (0-1) → persisted per-file settings
|
||||
// (videos.face_filter, min_confidence 0-100) → None (caller uses Apple Vision defaults 0.5/1).
|
||||
let face_settings_json = if let Some(fs) = req.face_settings.as_ref() {
|
||||
Some(serde_json::json!({
|
||||
"min_confidence": fs.min_confidence.unwrap_or(0.5),
|
||||
"min_size": fs.min_size.unwrap_or(1)
|
||||
}))
|
||||
} else if let Some(v) = face_filter.as_ref() {
|
||||
let min_conf_pct = v
|
||||
.get("min_confidence")
|
||||
.and_then(|x| x.as_f64())
|
||||
.unwrap_or(50.0);
|
||||
let min_size = v.get("min_size").and_then(|x| x.as_i64()).unwrap_or(1) as i32;
|
||||
Some(serde_json::json!({
|
||||
"min_confidence": min_conf_pct / 100.0,
|
||||
"min_size": min_size
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(job_id) = existing_id {
|
||||
// Clean up stale processor_results from previous runs
|
||||
@@ -304,7 +325,11 @@ async fn trigger_processing(
|
||||
.execute(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("[TRIGGER] Failed to update face_settings for job {}: {}", job_id, e);
|
||||
tracing::error!(
|
||||
"[TRIGGER] Failed to update face_settings for job {}: {}",
|
||||
job_id,
|
||||
e
|
||||
);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user