refactor: cargo fmt across 27 files + behavioral fixes

Behavioral changes:
- postgres_db: reorder default processors (cut first), prevent overwriting completed status
- qdrant_db: fix scroll pagination exit condition (next.is_none())
- job_worker: add idempotency guards for face trace / TKG build; better error logging
- main.rs: add LineWriter for stdout buffering

Remaining diff is cargo fmt reformatting (line wrapping, import ordering).
This commit is contained in:
Accusys
2026-07-11 02:03:28 +08:00
parent 701727fd08
commit b98a362de5
27 changed files with 1216 additions and 546 deletions
+74 -45
View File
@@ -232,20 +232,29 @@ async fn bbox_overlay_video(
{"key": "trace_id", "match": {"value": 1}}
]
});
let points = qdrant.scroll_all_points("_faces", face_filter, 500).await.unwrap_or_default();
let points = qdrant
.scroll_all_points("_faces", face_filter, 500)
.await
.unwrap_or_default();
let rows: Vec<(i64, i32, i32, i32, i32, Option<i32>, Option<String>)> = points.iter().filter_map(|p| {
let payload = &p["payload"];
let frame = payload["frame"].as_i64()?;
let bbox = &payload["bbox"];
let x = bbox["x"].as_f64()? as i32;
let y = bbox["y"].as_f64()? as i32;
let w = bbox["width"].as_f64()? as i32;
let h = bbox["height"].as_f64()? as i32;
let trace_id = payload["trace_id"].as_i64().map(|t| t as i32);
let face_id = payload.get("face_id").and_then(|v| v.as_str()).map(|s| s.to_string());
Some((frame, x, y, w, h, trace_id, face_id))
}).collect();
let rows: Vec<(i64, i32, i32, i32, i32, Option<i32>, Option<String>)> = points
.iter()
.filter_map(|p| {
let payload = &p["payload"];
let frame = payload["frame"].as_i64()?;
let bbox = &payload["bbox"];
let x = bbox["x"].as_f64()? as i32;
let y = bbox["y"].as_f64()? as i32;
let w = bbox["width"].as_f64()? as i32;
let h = bbox["height"].as_f64()? as i32;
let trace_id = payload["trace_id"].as_i64().map(|t| t as i32);
let face_id = payload
.get("face_id")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
Some((frame, x, y, w, h, trace_id, face_id))
})
.collect();
// Build filters — each bbox enabled only on its frame
let mut parts: Vec<String> = Vec::new();
@@ -362,18 +371,24 @@ async fn trace_video_inner(
{"key": "trace_id", "match": {"value": trace_id}}
]
});
let points = qdrant.scroll_all_points("_faces", trace_filter, 500).await.unwrap_or_default();
let points = qdrant
.scroll_all_points("_faces", trace_filter, 500)
.await
.unwrap_or_default();
let rows: Vec<(i64, i32, i32, i32, i32)> = points.iter().filter_map(|p| {
let payload = &p["payload"];
let frame = payload["frame"].as_i64()?;
let bbox = &payload["bbox"];
let x = bbox["x"].as_f64()? as i32;
let y = bbox["y"].as_f64()? as i32;
let w = bbox["width"].as_f64()? as i32;
let h = bbox["height"].as_f64()? as i32;
Some((frame, x, y, w, h))
}).collect();
let rows: Vec<(i64, i32, i32, i32, i32)> = points
.iter()
.filter_map(|p| {
let payload = &p["payload"];
let frame = payload["frame"].as_i64()?;
let bbox = &payload["bbox"];
let x = bbox["x"].as_f64()? as i32;
let y = bbox["y"].as_f64()? as i32;
let w = bbox["width"].as_f64()? as i32;
let h = bbox["height"].as_f64()? as i32;
Some((frame, x, y, w, h))
})
.collect();
if rows.is_empty() {
return Err(StatusCode::NOT_FOUND);
@@ -424,13 +439,20 @@ async fn trace_video_inner(
// Query all traces with identity names and bbox positions in the visible frame range
let identities_table = schema::table_name("identities");
let all_points = qdrant.scroll_all_points("_faces", json!({
"must": [
{"key": "file_uuid", "match": {"value": file_uuid}},
{"key": "frame", "range": {"gte": start_fn, "lte": end_fn}},
{"key": "trace_id", "match": {"value": 1}}
]
}), 1000).await.unwrap_or_default();
let all_points = qdrant
.scroll_all_points(
"_faces",
json!({
"must": [
{"key": "file_uuid", "match": {"value": file_uuid}},
{"key": "frame", "range": {"gte": start_fn, "lte": end_fn}},
{"key": "trace_id", "match": {"value": 1}}
]
}),
1000,
)
.await
.unwrap_or_default();
// Get identity names for traces that have identity_id
let mut identity_names: HashMap<i32, String> = HashMap::new();
@@ -455,18 +477,21 @@ async fn trace_video_inner(
}
}
let all_rows: Vec<(i32, i64, i32, i32, i32, i32, Option<String>)> = all_points.iter().filter_map(|p| {
let payload = &p["payload"];
let trace_id = payload["trace_id"].as_i64()? as i32;
let frame = payload["frame"].as_i64()?;
let bbox = &payload["bbox"];
let x = bbox["x"].as_f64()? as i32;
let y = bbox["y"].as_f64()? as i32;
let w = bbox["width"].as_f64()? as i32;
let h = bbox["height"].as_f64()? as i32;
let name = identity_names.get(&trace_id).cloned();
Some((trace_id, frame, x, y, w, h, name))
}).collect();
let all_rows: Vec<(i32, i64, i32, i32, i32, i32, Option<String>)> = all_points
.iter()
.filter_map(|p| {
let payload = &p["payload"];
let trace_id = payload["trace_id"].as_i64()? as i32;
let frame = payload["frame"].as_i64()?;
let bbox = &payload["bbox"];
let x = bbox["x"].as_f64()? as i32;
let y = bbox["y"].as_f64()? as i32;
let w = bbox["width"].as_f64()? as i32;
let h = bbox["height"].as_f64()? as i32;
let name = identity_names.get(&trace_id).cloned();
Some((trace_id, frame, x, y, w, h, name))
})
.collect();
// Group frames by trace_id, compute start_frame per trace; collect bbox per frame
// frame_number is i64 (BIGINT), so HashMaps need i64 for frame values
@@ -1169,9 +1194,13 @@ async fn stranger_video_inner(
{"key": "stranger_id", "match": {"value": stranger_id}}
]
});
let points = qdrant.scroll_all_points("_faces", face_filter, 1000).await.unwrap_or_default();
let points = qdrant
.scroll_all_points("_faces", face_filter, 1000)
.await
.unwrap_or_default();
let rows: Vec<(i64, i32, i32, i32, i32)> = points.iter()
let rows: Vec<(i64, i32, i32, i32, i32)> = points
.iter()
.filter_map(|p| {
let payload = &p["payload"];
let frame = payload["frame"].as_i64()?;