feat: fix TKG external_id mismatch, add trace delete/merge endpoints, fix no-faces progress update
- identity_binding.rs: match both face_track_N and trace_N external_id formats in bind/unbind/create_pending_person - profile.rs: fix external_id matching and parameter ordering in trace profile updates - trace_agent_api.rs: add DELETE /trace/:id (soft/hard delete) and POST /trace/:src/merge/:target endpoints - qdrant_db.rs: add delete_points_by_filter method - tkg.rs: add debug logging for scroll and parse operations - job_worker.rs: update progress for no-faces TKG path
This commit is contained in:
+42
-24
@@ -304,24 +304,31 @@ pub async fn unbind_identity(
|
||||
);
|
||||
}
|
||||
|
||||
// Update TKG: restore stranger_ref and remove identity fields
|
||||
// Update TKG: restore stranger_ref and remove identity fields (match both external_id formats)
|
||||
if let Some(tid) = trace_id {
|
||||
let tkg_table = crate::core::db::schema::table_name("tkg_nodes");
|
||||
let ext_id = format!("face_track_{}", tid);
|
||||
let ext_id_face = format!("face_track_{}", tid);
|
||||
let ext_id_trace = format!("trace_{}", tid);
|
||||
let stranger_ref = format!("{}:stranger_trace_{}", req.file_uuid, tid);
|
||||
|
||||
let _ = sqlx::query(&format!(
|
||||
let result = sqlx::query(&format!(
|
||||
"UPDATE {} SET properties = properties || $1::jsonb - 'identity_uuid' - 'identity_ref' - 'identity_id' - 'identity_name' \
|
||||
WHERE file_uuid = $2 AND node_type = 'face_track' AND external_id = $3",
|
||||
WHERE file_uuid = $2 AND node_type = 'face_track' AND (external_id = $3 OR external_id = $4)",
|
||||
tkg_table
|
||||
))
|
||||
.bind(serde_json::json!({
|
||||
"stranger_ref": stranger_ref
|
||||
}))
|
||||
.bind(&req.file_uuid)
|
||||
.bind(&ext_id)
|
||||
.bind(&ext_id_face)
|
||||
.bind(&ext_id_trace)
|
||||
.execute(state.db.pool())
|
||||
.await;
|
||||
|
||||
match &result {
|
||||
Ok(r) => tracing::info!("[unbind_identity] TKG update: {} rows affected for trace {}", r.rows_affected(), tid),
|
||||
Err(e) => tracing::error!("[unbind_identity] TKG update failed: {}", e),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(identity_id) = old_identity_id {
|
||||
@@ -887,9 +894,10 @@ pub async fn bind_identity_trace(
|
||||
);
|
||||
}
|
||||
|
||||
// Update TKG node properties
|
||||
// Update TKG node properties (match both face_track_N and trace_N external_id formats)
|
||||
let nodes_table = crate::core::db::schema::table_name("tkg_nodes");
|
||||
let external_id = format!("face_track_{}", req.trace_id);
|
||||
let external_id_face = format!("face_track_{}", req.trace_id);
|
||||
let external_id_trace = format!("trace_{}", req.trace_id);
|
||||
let identity_name: Option<String> =
|
||||
sqlx::query_scalar(&format!("SELECT name FROM {} WHERE id = $1", id_table))
|
||||
.bind(identity_id)
|
||||
@@ -898,20 +906,27 @@ pub async fn bind_identity_trace(
|
||||
.ok()
|
||||
.flatten();
|
||||
|
||||
let _ = sqlx::query(&format!(
|
||||
"UPDATE {} SET properties = jsonb_set(\
|
||||
jsonb_set(properties, '{{identity_id}}', $1::jsonb, false),\
|
||||
'{{identity_name}}', $2::jsonb, false)\
|
||||
WHERE file_uuid = $3 AND node_type = 'face_track' AND external_id = $4",
|
||||
let new_props = serde_json::json!({
|
||||
"identity_id": identity_id,
|
||||
"identity_name": identity_name
|
||||
});
|
||||
let result = sqlx::query(&format!(
|
||||
"UPDATE {} SET properties = properties || $1::jsonb \
|
||||
WHERE file_uuid = $2 AND node_type = 'face_track' AND (external_id = $3 OR external_id = $4)",
|
||||
nodes_table
|
||||
))
|
||||
.bind(identity_id)
|
||||
.bind(identity_name.as_deref())
|
||||
.bind(serde_json::to_string(&new_props).unwrap())
|
||||
.bind(&req.file_uuid)
|
||||
.bind(&external_id)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.execute(state.db.pool())
|
||||
.await;
|
||||
|
||||
match &result {
|
||||
Ok(r) => tracing::info!("[bind_identity_trace] TKG update: {} rows affected for trace {}", r.rows_affected(), req.trace_id),
|
||||
Err(e) => tracing::error!("[bind_identity_trace] TKG update failed: {}", e),
|
||||
}
|
||||
|
||||
// Clear bind redo stack
|
||||
let _ = sqlx::query(&format!(
|
||||
"DELETE FROM {} WHERE identity_id = $1 AND is_undone = true AND operation IN ('bind','unbind','bind_trace')",
|
||||
@@ -2040,20 +2055,23 @@ pub async fn create_pending_person(
|
||||
}
|
||||
}
|
||||
|
||||
// Update TKG nodes
|
||||
// Update TKG nodes (match both face_track_N and trace_N external_id formats)
|
||||
for &tid in &req.trace_ids {
|
||||
let external_id = format!("face_track_{}", tid);
|
||||
let external_id_face = format!("face_track_{}", tid);
|
||||
let external_id_trace = format!("trace_{}", tid);
|
||||
let new_props = serde_json::json!({
|
||||
"identity_id": identity_id,
|
||||
"identity_name": name
|
||||
});
|
||||
let _ = sqlx::query(&format!(
|
||||
"UPDATE {} SET properties = jsonb_set(\
|
||||
jsonb_set(properties, '{{identity_id}}', $1::jsonb, false),\
|
||||
'{{identity_name}}', $2::jsonb, false)\
|
||||
WHERE file_uuid = $3 AND node_type = 'face_track' AND external_id = $4",
|
||||
"UPDATE {} SET properties = properties || $1::jsonb \
|
||||
WHERE file_uuid = $2 AND node_type = 'face_track' AND (external_id = $3 OR external_id = $4)",
|
||||
nodes_table
|
||||
))
|
||||
.bind(identity_id)
|
||||
.bind(&name)
|
||||
.bind(serde_json::to_string(&new_props).unwrap())
|
||||
.bind(&file_uuid)
|
||||
.bind(&external_id)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.execute(state.db.pool())
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user