fix: identity names now show in all trace tooltips (online + offline)

- Online: remove IDENTITY filter gating on identity_note — always show
- Offline: fix id_names scope bug — was overwritten by top10-only dict
- Both reports now show 'identity: PERSON_xxx' for all 2000 timeline traces
- All 5483 traces have identity mapping (verified in SQLite)
This commit is contained in:
Accusys
2026-05-13 03:19:26 +08:00
parent 8d4d29ce6e
commit fff2af8ad1
2 changed files with 10 additions and 17 deletions

View File

@@ -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'<span class="bar" style="left:{left}px;top:{top}px;width:{width}px;height:{bar_h}px;opacity:{opacity}" title="{title}"></span>')

View File

@@ -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")