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:
+29
-12
@@ -249,7 +249,10 @@ pub async fn unbind_identity(
|
||||
{"key": "trace_id", "match": {"value": tid}}
|
||||
]
|
||||
});
|
||||
let points = qdrant.scroll_points("_faces", filter, 1, None).await.unwrap_or_default();
|
||||
let points = qdrant
|
||||
.scroll_points("_faces", filter, 1, None)
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
points.0.first().map(|p| {
|
||||
let identity_id = p["payload"]["identity_id"].as_i64().map(|i| i as i32);
|
||||
(identity_id, Some(tid))
|
||||
@@ -260,7 +263,9 @@ pub async fn unbind_identity(
|
||||
None
|
||||
} else {
|
||||
// face_id lookup not supported in Qdrant
|
||||
tracing::warn!("[unbind_identity] face_id field lookup not supported, use trace_id instead");
|
||||
tracing::warn!(
|
||||
"[unbind_identity] face_id field lookup not supported, use trace_id instead"
|
||||
);
|
||||
None
|
||||
};
|
||||
|
||||
@@ -440,7 +445,6 @@ pub async fn merge_identities(
|
||||
Path(identity_uuid): Path<String>,
|
||||
Json(req): Json<MergeIdentitiesRequest>,
|
||||
) -> Result<Json<ApiResponse<serde_json::Value>>, (StatusCode, Json<serde_json::Value>)> {
|
||||
|
||||
let id_table = crate::core::db::schema::table_name("identities");
|
||||
|
||||
let db = sqlx::PgPool::connect(&crate::core::config::DATABASE_URL)
|
||||
@@ -523,10 +527,17 @@ pub async fn merge_identities(
|
||||
{"key": "identity_id", "match": {"value": from_id}}
|
||||
]
|
||||
});
|
||||
let points = qdrant.scroll_all_points("_faces", face_filter, 1000).await.unwrap_or_default();
|
||||
let face_ids: Vec<(Option<String>, Option<i32>)> = points.iter()
|
||||
let points = qdrant
|
||||
.scroll_all_points("_faces", face_filter, 1000)
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
let face_ids: Vec<(Option<String>, Option<i32>)> = points
|
||||
.iter()
|
||||
.map(|p| {
|
||||
let face_id = p["payload"].get("face_id").and_then(|v| v.as_str()).map(|s| s.to_string());
|
||||
let face_id = p["payload"]
|
||||
.get("face_id")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.to_string());
|
||||
let trace_id = p["payload"]["trace_id"].as_i64().map(|t| t as i32);
|
||||
(face_id, trace_id)
|
||||
})
|
||||
@@ -537,7 +548,8 @@ pub async fn merge_identities(
|
||||
let faces_count = face_id_list.len() as i64;
|
||||
|
||||
// Get file_uuid for these faces (from Qdrant)
|
||||
let file_uuid: Option<String> = points.first()
|
||||
let file_uuid: Option<String> = points
|
||||
.first()
|
||||
.and_then(|p| p["payload"]["file_uuid"].as_str())
|
||||
.map(|s| s.to_string());
|
||||
|
||||
@@ -1651,7 +1663,9 @@ async fn apply_bind_snapshot(
|
||||
// Legacy face_id path not supported - no trace_id in snapshot
|
||||
Err((
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(serde_json::json!({"error": "Snapshot has no trace_id, legacy face_id path not supported"})),
|
||||
Json(
|
||||
serde_json::json!({"error": "Snapshot has no trace_id, legacy face_id path not supported"}),
|
||||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -1789,8 +1803,7 @@ pub async fn bind_redo(
|
||||
let after = &records.last().unwrap().2;
|
||||
|
||||
let identity_id_after = after.get("identity_id_after").cloned();
|
||||
let affected_rows =
|
||||
apply_bind_snapshot(state.db.pool(), "", after, identity_id_after).await?;
|
||||
let affected_rows = apply_bind_snapshot(state.db.pool(), "", after, identity_id_after).await?;
|
||||
|
||||
// Mark all as redone
|
||||
for (history_id, _, _) in &records {
|
||||
@@ -2098,8 +2111,12 @@ pub async fn list_pending_persons(
|
||||
{"key": "identity_id", "match": {"value": id}}
|
||||
]
|
||||
});
|
||||
let points = qdrant.scroll_all_points("_faces", face_filter, 500).await.unwrap_or_default();
|
||||
let unique_traces: std::collections::HashSet<i64> = points.iter()
|
||||
let points = qdrant
|
||||
.scroll_all_points("_faces", face_filter, 500)
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
let unique_traces: std::collections::HashSet<i64> = points
|
||||
.iter()
|
||||
.filter_map(|p| p["payload"]["trace_id"].as_i64())
|
||||
.collect();
|
||||
let trace_count = unique_traces.len() as i64;
|
||||
|
||||
Reference in New Issue
Block a user