diff --git a/scripts/render_face_heatmap.py b/scripts/render_face_heatmap.py index 707e6a2..f66398d 100644 --- a/scripts/render_face_heatmap.py +++ b/scripts/render_face_heatmap.py @@ -84,15 +84,15 @@ if IDENTITY is None: GROUP BY fd.identity_id, i.name ORDER BY faces DESC LIMIT 10 """, (UUID,)) top_identities = cur.fetchall() -else: - # Get trace→identity mapping for tooltip enrichment - cur.execute(""" - SELECT DISTINCT fd.trace_id, i.name - FROM dev.face_detections fd - LEFT JOIN dev.identities i ON i.id = fd.identity_id - WHERE fd.file_uuid=%s AND fd.identity_id IS NOT NULL - """, (UUID,)) - trace_to_identity = {r[0]: r[1] for r in cur.fetchall()} + +# Always get trace→identity mapping for tooltip enrichment +cur.execute(""" + SELECT DISTINCT fd.trace_id, i.name + FROM dev.face_detections fd + LEFT JOIN dev.identities i ON i.id = fd.identity_id + WHERE fd.file_uuid=%s AND fd.identity_id IS NOT NULL +""", (UUID,)) +trace_to_identity = {r[0]: r[1] for r in cur.fetchall()} cur.close(); conn.close() @@ -185,7 +185,7 @@ def build_html(): top = i * (bar_h + 1) + 5 opacity = 1.0 if cnt > 5 else 0.3 identity_note = "" - if IDENTITY is not None and tid in trace_to_identity: + if tid in trace_to_identity: identity_note = f", identity: {trace_to_identity[tid]}" title = f"T{tid}: {t0:.0f}s–{t1:.0f}s, {cnt} faces, f{fn0}–f{fn1}{identity_note}" h.append(f'') diff --git a/scripts/render_offline_report.py b/scripts/render_offline_report.py index 1ef5481..9327f0b 100644 --- a/scripts/render_offline_report.py +++ b/scripts/render_offline_report.py @@ -98,13 +98,6 @@ if IDENTITY is not None: else: c.execute("SELECT identity_id, COUNT(*) as fc, COUNT(DISTINCT trace_id) as tc FROM face_detections WHERE identity_id IS NOT NULL GROUP BY identity_id ORDER BY fc DESC LIMIT 10") top_identities = c.fetchall() - # Get identity names - id_names = {} - if top_identities: - ids = [r[0] for r in top_identities] - placeholders = ",".join(["?" for _ in ids]) - c.execute(f"SELECT id, name FROM identities WHERE id IN ({placeholders})", ids) - id_names = {r[0]: r[1] for r in c.fetchall()} # TKG stats c.execute("SELECT COUNT(*) FROM tkg_nodes")