Ajoute vue détail par passage (clip + galerie frames)

- Sauvegarde le clip MP4 et les top 10 frames par événement dans /data/events/{id}/
- Nouvelle route GET /event/{id} avec page détail : info, vignette interactive, lecteur vidéo, galerie frames
- Les cartes de l'index sont maintenant cliquables
- Migration DB : ajout colonne clip_path sur les BDD existantes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
perco
2026-06-02 15:52:12 +02:00
co-authored by Claude Sonnet 4.6
parent 8507987ea9
commit 528a158c42
6 changed files with 261 additions and 83 deletions
+17 -4
View File
@@ -16,12 +16,18 @@ def init_db():
camera TEXT,
start_time INTEGER,
snapshot_path TEXT,
clip_path TEXT,
plate TEXT,
color_hex TEXT,
color_name TEXT,
processed_at INTEGER
)
""")
# Migrate existing DBs that lack clip_path
try:
conn.execute("ALTER TABLE events ADD COLUMN clip_path TEXT")
except Exception:
pass
conn.commit()
conn.close()
@@ -31,14 +37,14 @@ def event_exists(event_id: str) -> bool:
conn.close()
return row is not None
def insert_event(event_id, camera, start_time, snapshot_path, plate, color_hex, color_name):
def insert_event(event_id, camera, start_time, snapshot_path, clip_path, plate, color_hex, color_name):
import time
conn = get_db()
conn.execute("""
INSERT OR IGNORE INTO events
(id, camera, start_time, snapshot_path, plate, color_hex, color_name, processed_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
""", (event_id, camera, start_time, snapshot_path, plate, color_hex, color_name, int(time.time())))
(id, camera, start_time, snapshot_path, clip_path, plate, color_hex, color_name, processed_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (event_id, camera, start_time, snapshot_path, clip_path, plate, color_hex, color_name, int(time.time())))
conn.commit()
conn.close()
@@ -94,6 +100,13 @@ def count_events(plate_filter=None, camera_filter=None, date_filter=None):
conn.close()
return count
def get_event(event_id: str) -> dict | None:
conn = get_db()
row = conn.execute("SELECT * FROM events WHERE id = ?", (event_id,)).fetchone()
conn.close()
return dict(row) if row else None
def get_cameras():
conn = get_db()
rows = conn.execute("SELECT DISTINCT camera FROM events ORDER BY camera").fetchall()