VIDEO NOT IMAGES + history4all

This commit is contained in:
lda committed 2026-03-01 14:17:41 +07:00
1 parent c716d23151
commit 4201a3cbb1
6 files changed
+66 -13

No files matched your search

+5 -2
View File
@@ -122,10 +122,13 @@ class MySQLRepository:
conn.close()
return [DetectionRecord(**r) for r in rows]
def clear_detections(self, user_id: int) -> int:
def clear_detections(self, user_id: Optional[int] = None) -> int:
conn = self._connect()
cursor = conn.cursor()
cursor.execute("DELETE FROM detections WHERE user_id = %s", (user_id,))
if user_id is None:
cursor.execute("DELETE FROM detections")
else:
cursor.execute("DELETE FROM detections WHERE user_id = %s", (user_id,))
conn.commit()
count = cursor.rowcount
conn.close()
+2 -2
View File
@@ -59,8 +59,8 @@ class Repository(Protocol):
"""Get detection history, optionally filtered by user. Newest first."""
...
def clear_detections(self, user_id: int) -> int:
"""Delete all detections for a user. Returns number of rows deleted."""
def clear_detections(self, user_id: Optional[int] = None) -> int:
"""Delete detections, optionally filtered by user. Returns rows deleted."""
...
def close(self) -> None:
+7 -2
View File
@@ -109,9 +109,14 @@ class SQLiteRepository:
).fetchall()
return [DetectionRecord(**dict(r)) for r in rows]
def clear_detections(self, user_id: int) -> int:
def clear_detections(self, user_id: Optional[int] = None) -> int:
conn = self._get_conn()
cursor = conn.execute("DELETE FROM detections WHERE user_id = ?", (user_id,))
if user_id is None:
cursor = conn.execute("DELETE FROM detections")
else:
cursor = conn.execute(
"DELETE FROM detections WHERE user_id = ?", (user_id,)
)
conn.commit()
return cursor.rowcount