fix: add DISTINCT ON to cluster-results handler to prevent duplicate group cards

This commit is contained in:
Accusys
2026-11-02 18:59:54 +08:00
parent eebaa11bfb
commit ada49d3491
+4 -2
View File
@@ -1519,9 +1519,11 @@ pub async fn get_cluster_results_handler(
.unwrap_or_else(crate::core::file_profile::FaceFilterSettings::defaults);
// 1. Build face groups from TKG nodes (primary source)
// Use tkg_nodes.label as primary name, fallback to trace_profiles.name
// Use COALESCE(tn.label, tp.name) - tkg_nodes.label as primary, fallback to trace_profiles.name
// FIX: Use DISTINCT ON to prevent duplicate groups from duplicate tkg_nodes entries
let rows: Vec<(String, i32, Option<i32>)> = sqlx::query_as(&format!(
"SELECT COALESCE(tn.label, tp.name) as name, \
"SELECT DISTINCT ON (COALESCE(tp.trace_id, (tn.properties->>'trace_id')::int)) \
COALESCE(tn.label, tp.name) as name, \
COALESCE(tp.trace_id, (tn.properties->>'trace_id')::int) as trace_id, \
tp.frame_count \
FROM {} tn \