fix: face_detections INSERT in pipeline, add dependency graph doc

This commit is contained in:
Accusys
2026-05-17 22:16:20 +08:00
parent d6c8930f84
commit a880c80556
4 changed files with 149 additions and 24 deletions

View File

@@ -2193,6 +2193,21 @@ impl PostgresDb {
Ok(())
}
pub async fn store_face_detections_batch(
&self, uuid: &str, detections: &[(i64, f64, i32, i32, i32, i32, f32)]
) -> Result<()> {
let table = schema::table_name("face_detections");
for (frame, ts, x, y, w, h, conf) in detections {
sqlx::query(&format!(
"INSERT INTO {} (file_uuid, frame_number, timestamp_secs, x, y, width, height, confidence) \
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING", table
))
.bind(uuid).bind(frame).bind(ts).bind(x).bind(y).bind(w).bind(h).bind(conf)
.execute(&self.pool).await?;
}
Ok(())
}
pub async fn store_scene_pre_chunks_batch(&self, uuid: &str, scenes: &[(i64, i64, i64, f64, f64, serde_json::Value)]) -> Result<()> {
let table = schema::table_name("pre_chunks");
for (_i, _sf, _ef, start, end, data) in scenes {

View File

@@ -887,12 +887,14 @@ impl ProcessorPool {
) -> Result<()> {
let frames_count = face_result.frames.len();
tracing::info!(
"Storing {} Face pre-chunks for video {}",
"Storing {} Face pre-chunks + {} detections for video {}",
frames_count,
face_result.frames.iter().map(|f| f.faces.len()).sum::<usize>(),
uuid
);
let mut pre_chunks_to_store = Vec::new();
let mut detections_to_store = Vec::new();
for frame in face_result.frames.iter() {
let data = serde_json::json!({
@@ -901,10 +903,21 @@ impl ProcessorPool {
});
pre_chunks_to_store.push((frame.frame as i64, Some(frame.timestamp), data, None, None));
for face in frame.faces.iter() {
detections_to_store.push((
frame.frame as i64,
frame.timestamp,
face.x, face.y, face.width, face.height,
face.confidence,
));
}
}
db.store_raw_pre_chunks_batch(uuid, "face", &pre_chunks_to_store)
.await?;
db.store_face_detections_batch(uuid, &detections_to_store)
.await?;
Ok(())
}