feat: add per-file face_settings (min_confidence, min_size) support
- DB: Added face_settings jsonb column to monitor_jobs - API: RegisterFileRequest accepts face_settings - DB: create_monitor_job accepts and stores face_settings - MonitorJob struct includes face_settings field - Swift face processor will read from FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars
This commit is contained in:
@@ -452,6 +452,7 @@ pub struct MonitorJob {
|
||||
pub completed_processors: Vec<String>,
|
||||
pub failed_processors: Vec<String>,
|
||||
pub video_id: Option<i64>,
|
||||
pub face_settings: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -1946,6 +1947,7 @@ impl PostgresDb {
|
||||
&self,
|
||||
uuid: &str,
|
||||
video_path: Option<&str>,
|
||||
face_settings: Option<&serde_json::Value>,
|
||||
) -> Result<MonitorJob> {
|
||||
let videos_table = schema::table_name("videos");
|
||||
let jobs_table = schema::table_name("monitor_jobs");
|
||||
@@ -1969,20 +1971,23 @@ impl PostgresDb {
|
||||
.fetch_optional(&self.pool)
|
||||
.await?;
|
||||
|
||||
let face_settings_json = face_settings.map(|v| v.to_string()).unwrap_or_else(|| "{\"min_confidence\": 0.75, \"min_size\": 64}".to_string());
|
||||
|
||||
let row = if let Some(job_id) = existing_id {
|
||||
// Update existing job
|
||||
sqlx::query(
|
||||
&format!(
|
||||
r#"
|
||||
UPDATE {} SET status = 'pending', video_path = $1, video_id = $2, updated_at = NOW()
|
||||
WHERE id = $3
|
||||
RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id
|
||||
UPDATE {} SET status = 'pending', video_path = $1, video_id = $2, face_settings = $3::jsonb, updated_at = NOW()
|
||||
WHERE id = $4
|
||||
RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id, face_settings::text
|
||||
"#,
|
||||
jobs_table
|
||||
)
|
||||
)
|
||||
.bind(video_path)
|
||||
.bind(video_id_i64)
|
||||
.bind(&face_settings_json)
|
||||
.bind(job_id)
|
||||
.fetch_one(&self.pool)
|
||||
.await?
|
||||
@@ -1991,9 +1996,9 @@ impl PostgresDb {
|
||||
sqlx::query(
|
||||
&format!(
|
||||
r#"
|
||||
INSERT INTO {} (uuid, video_path, status, video_id, processors)
|
||||
VALUES ($1, $2, 'pending', $3, ARRAY['cut','asr','face','ocr','asrx','pose'])
|
||||
RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id
|
||||
INSERT INTO {} (uuid, video_path, status, video_id, processors, face_settings)
|
||||
VALUES ($1, $2, 'pending', $3, ARRAY['cut','asr','face','ocr','asrx','pose'], $4::jsonb)
|
||||
RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id, face_settings::text
|
||||
"#,
|
||||
jobs_table
|
||||
)
|
||||
@@ -2001,6 +2006,7 @@ impl PostgresDb {
|
||||
.bind(uuid)
|
||||
.bind(video_path)
|
||||
.bind(video_id_i64)
|
||||
.bind(&face_settings_json)
|
||||
.fetch_one(&self.pool)
|
||||
.await?
|
||||
};
|
||||
@@ -2009,6 +2015,9 @@ impl PostgresDb {
|
||||
let status =
|
||||
MonitorJobStatus::from_db_str(&status_str).unwrap_or(MonitorJobStatus::Pending);
|
||||
|
||||
let face_settings_raw: Option<String> = row.get(16);
|
||||
let face_settings = face_settings_raw.and_then(|s| serde_json::from_str(&s).ok());
|
||||
|
||||
Ok(MonitorJob {
|
||||
id: row.get(0),
|
||||
uuid: row.get(1),
|
||||
@@ -2026,6 +2035,7 @@ impl PostgresDb {
|
||||
completed_processors: row.get::<Option<Vec<String>>, _>(13).unwrap_or_default(),
|
||||
failed_processors: row.get::<Option<Vec<String>>, _>(14).unwrap_or_default(),
|
||||
video_id: row.get(15),
|
||||
face_settings,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2120,6 +2130,7 @@ impl PostgresDb {
|
||||
completed_processors: r.get::<Option<Vec<String>>, _>(13).unwrap_or_default(),
|
||||
failed_processors: r.get::<Option<Vec<String>>, _>(14).unwrap_or_default(),
|
||||
video_id: r.get(15),
|
||||
face_settings: r.get::<Option<String>, _>(16).and_then(|s| serde_json::from_str(&s).ok()),
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -2168,6 +2179,7 @@ impl PostgresDb {
|
||||
completed_processors: r.get::<Option<Vec<String>>, _>(13).unwrap_or_default(),
|
||||
failed_processors: r.get::<Option<Vec<String>>, _>(14).unwrap_or_default(),
|
||||
video_id: r.get(15),
|
||||
face_settings: r.get::<Option<String>, _>(16).and_then(|s| serde_json::from_str(&s).ok()),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -4906,6 +4918,7 @@ mod tests {
|
||||
completed_processors: vec!["asr".to_string()],
|
||||
failed_processors: vec![],
|
||||
video_id: None,
|
||||
face_settings: None,
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&job).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user