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>,
|
Json(req): Json<ProcessRequest>,
|
||||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||||
let videos_table = schema::table_name("videos");
|
let videos_table = schema::table_name("videos");
|
||||||
let row: Option<(String, String, String, Option<String>, String, Option<String>)> =
|
let row: Option<(
|
||||||
sqlx::query_as(&format!(
|
String,
|
||||||
"SELECT file_uuid, file_path, file_name, file_type, COALESCE(processing_status::text, 'REGISTERED'), content_hash FROM {} WHERE file_uuid = $1",
|
String,
|
||||||
videos_table
|
String,
|
||||||
))
|
Option<String>,
|
||||||
.bind(&uuid)
|
String,
|
||||||
.fetch_optional(state.db.pool())
|
Option<String>,
|
||||||
.await
|
Option<serde_json::Value>,
|
||||||
.map_err(|e| {
|
)> = sqlx::query_as(&format!(
|
||||||
tracing::error!("DB error: {}", e);
|
"SELECT file_uuid, file_path, file_name, file_type, COALESCE(processing_status::text, 'REGISTERED'), content_hash, face_filter FROM {} WHERE file_uuid = $1",
|
||||||
StatusCode::INTERNAL_SERVER_ERROR
|
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)?;
|
row.ok_or(StatusCode::NOT_FOUND)?;
|
||||||
|
|
||||||
if processing_status == "PROCESSING" || processing_status == "QUEUED" {
|
if processing_status == "PROCESSING" || processing_status == "QUEUED" {
|
||||||
@@ -267,13 +274,27 @@ async fn trigger_processing(
|
|||||||
.await
|
.await
|
||||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||||
|
|
||||||
// Convert face_settings to serde_json::Value for create_monitor_job
|
// Convert face_settings to serde_json::Value for create_monitor_job.
|
||||||
let face_settings_json = req.face_settings.as_ref().map(|fs| {
|
// Priority: explicit request settings (0-1) → persisted per-file settings
|
||||||
serde_json::json!({
|
// (videos.face_filter, min_confidence 0-100) → None (caller uses Apple Vision defaults 0.5/1).
|
||||||
"min_confidence": fs.min_confidence.unwrap_or(0.75),
|
let face_settings_json = if let Some(fs) = req.face_settings.as_ref() {
|
||||||
"min_size": fs.min_size.unwrap_or(64)
|
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 {
|
if let Some(job_id) = existing_id {
|
||||||
// Clean up stale processor_results from previous runs
|
// Clean up stale processor_results from previous runs
|
||||||
@@ -304,7 +325,11 @@ async fn trigger_processing(
|
|||||||
.execute(state.db.pool())
|
.execute(state.db.pool())
|
||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.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
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user