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:
+28
-19
@@ -55,15 +55,17 @@ pub async fn get_trace_profile_handler(
|
||||
Query(params): Query<TraceProfileQuery>,
|
||||
) -> Result<Json<TraceProfile>, StatusCode> {
|
||||
let tkg_table = schema::table_name("tkg_nodes");
|
||||
let external_id = format!("face_track_{}", params.trace_id);
|
||||
let external_id_face = format!("face_track_{}", params.trace_id);
|
||||
let external_id_trace = format!("trace_{}", params.trace_id);
|
||||
|
||||
let row: Option<(String, String, serde_json::Value)> = sqlx::query_as(&format!(
|
||||
"SELECT label, external_id, properties FROM {} \
|
||||
WHERE file_uuid = $1 AND node_type = 'face_track' AND external_id = $2",
|
||||
WHERE file_uuid = $1 AND node_type = 'face_track' AND (external_id = $2 OR external_id = $3)",
|
||||
tkg_table
|
||||
))
|
||||
.bind(¶ms.file_uuid)
|
||||
.bind(&external_id)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
@@ -99,16 +101,18 @@ pub async fn update_trace_profile_handler(
|
||||
Json(req): Json<UpdateTraceProfileRequest>,
|
||||
) -> Result<Json<serde_json::Value>, StatusCode> {
|
||||
let tkg_table = 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);
|
||||
|
||||
// Get current node
|
||||
// Get current node (match both external_id formats)
|
||||
let current: Option<(String, serde_json::Value)> = sqlx::query_as(&format!(
|
||||
"SELECT label, properties FROM {} \
|
||||
WHERE file_uuid = $1 AND node_type = 'face_track' AND external_id = $2",
|
||||
WHERE file_uuid = $1 AND node_type = 'face_track' AND (external_id = $2 OR external_id = $3)",
|
||||
tkg_table
|
||||
))
|
||||
.bind(&req.file_uuid)
|
||||
.bind(&external_id)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
@@ -123,7 +127,7 @@ pub async fn update_trace_profile_handler(
|
||||
|
||||
if let Some(ref new_name) = req.name {
|
||||
if new_name != ¤t_label {
|
||||
updates.push(format!("label = $3"));
|
||||
updates.push(format!("label = $5"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,31 +162,34 @@ pub async fn update_trace_profile_handler(
|
||||
}
|
||||
|
||||
let mut query = format!(
|
||||
"UPDATE {} SET properties = $4",
|
||||
"UPDATE {} SET properties = properties || $4::jsonb",
|
||||
tkg_table
|
||||
);
|
||||
if !updates.is_empty() {
|
||||
query.push_str(", ");
|
||||
query.push_str(&updates.join(", "));
|
||||
}
|
||||
query.push_str(" WHERE file_uuid = $1 AND node_type = 'face_track' AND external_id = $2");
|
||||
query.push_str(" WHERE file_uuid = $1 AND node_type = 'face_track' AND (external_id = $2 OR external_id = $3)");
|
||||
|
||||
let param_idx = if updates.is_empty() { 3 } else { 4 };
|
||||
query.push_str(&format!(" RETURNING id"));
|
||||
query.push_str(" RETURNING id");
|
||||
|
||||
let props_json = serde_json::to_string(¤t_props).unwrap();
|
||||
|
||||
let result = if !updates.is_empty() {
|
||||
sqlx::query(&query)
|
||||
.bind(&req.file_uuid)
|
||||
.bind(&external_id)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.bind(&props_json)
|
||||
.bind(req.name.as_ref().unwrap_or(¤t_label))
|
||||
.bind(¤t_props)
|
||||
.execute(state.db.pool())
|
||||
.await
|
||||
} else {
|
||||
sqlx::query(&query)
|
||||
.bind(&req.file_uuid)
|
||||
.bind(&external_id)
|
||||
.bind(¤t_props)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.bind(&props_json)
|
||||
.execute(state.db.pool())
|
||||
.await
|
||||
};
|
||||
@@ -211,15 +218,17 @@ pub async fn update_trace_profile_group_handler(
|
||||
|
||||
let mut updated = 0;
|
||||
for trace_id in &req.trace_ids {
|
||||
let external_id = format!("face_track_{}", trace_id);
|
||||
let external_id_face = format!("face_track_{}", trace_id);
|
||||
let external_id_trace = format!("trace_{}", trace_id);
|
||||
let result = sqlx::query(&format!(
|
||||
"UPDATE {} SET label = $1 \
|
||||
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(&req.name)
|
||||
.bind(&req.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