fix: auto-update face track labels after clustering in worker pipeline

The P3 Face Dedup trigger previously only logged when cluster_count !=
face_track_count without actually syncing labels. Now it calls
update_face_track_labels to:
- UPDATE tkg_nodes SET label = cluster_id for each trace
- UPSERT trace_profiles SET name = cluster_id
- Reset unclustered traces to default Person_N name

This matches what the manual 'Face Deduplication' button in Studio
already does via the cluster-agent API endpoint, ensuring the automatic
pipeline produces the same result without requiring manual intervention.
This commit is contained in:
Accusys
2026-08-03 08:09:16 +08:00
parent 975c72eb49
commit 4d0d2204fd
+30 -1
View File
@@ -2485,10 +2485,39 @@ impl JobWorker {
uuid, cluster_count, face_track_count
);
} else {
// Labels not synced — update tkg_nodes and trace_profiles
info!(
"📝 Face dedup running for {}: {} clusters, {} tracks",
"📝 Face dedup running for {}: {} clusters, {} tracks — updating labels",
uuid, cluster_count, face_track_count
);
if let Ok(result) =
serde_json::from_value::<crate::core::processor::FaceClusterResult>(
cluster_data.clone()
)
{
let db_clone = self.db.clone();
let uuid_clone = uuid.to_string();
tokio::spawn(async move {
match Self::update_face_track_labels(
&db_clone,
&uuid_clone,
&result,
)
.await
{
Ok(()) => info!(
"✅ Face dedup labels updated for {}",
uuid_clone
),
Err(e) => error!(
"❌ Face dedup label update failed for {}: {}",
uuid_clone, e
),
}
});
} else {
warn!("Failed to parse face_cluster.json for {}", uuid);
}
}
}
}