Skip to content

Commit e64a3da

Browse files
Sbussisoclaude
andcommitted
Clean old logs without emails, fix email filter search
Clear pre-migration log entries that have no email stored. Update audit filter to search by email or user_id. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 11fb69c commit e64a3da

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

backend/app/api/audit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ async def get_stream_logs(
3030
query = query.filter(StreamAccessLog.camera_id == camera_id)
3131

3232
if user_id:
33-
query = query.filter(StreamAccessLog.user_id == user_id)
33+
query = query.filter(
34+
StreamAccessLog.user_email.ilike(f"%{user_id}%")
35+
| StreamAccessLog.user_id.ilike(f"%{user_id}%")
36+
)
3437

3538
total = query.count()
3639

backend/app/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
if "user_email" not in columns:
2121
conn.execute(text("ALTER TABLE stream_access_logs ADD COLUMN user_email VARCHAR(255) DEFAULT ''"))
2222
conn.commit()
23+
else:
24+
# Clear old test data that has no email (one-time cleanup)
25+
result = conn.execute(text("DELETE FROM stream_access_logs WHERE user_email = '' OR user_email IS NULL"))
26+
if result.rowcount > 0:
27+
conn.commit()
2328

2429
limiter = Limiter(key_func=lambda: "default")
2530

0 commit comments

Comments
 (0)