@@ -460,23 +460,23 @@ async def export_data():
460460 import io
461461 import zipfile
462462 from fastapi.responses import StreamingResponse
463-
463+
464464 try:
465465 # Create in-memory zip file
466466 zip_buffer = io.BytesIO()
467-
467+
468468 with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
469469 # Export request logs
470470 conn = sqlite3.connect(str(DB_PATH))
471471 conn.row_factory = sqlite3.Row
472472 cursor = conn.cursor()
473-
473+
474474 # Get all request logs
475475 cursor.execute('''
476476 SELECT * FROM request_logs ORDER BY created_at DESC
477477 ''')
478478 logs = cursor.fetchall()
479-
479+
480480 # Convert to JSON
481481 logs_data = []
482482 for row in logs:
@@ -487,28 +487,28 @@ async def export_data():
487487 except:
488488 pass
489489 logs_data.append(log_entry)
490-
490+
491491 # Add logs to zip
492492 zip_file.writestr("request_logs.json", json.dumps(logs_data, indent=2))
493-
493+
494494 # Export performance metrics if available
495495 try:
496496 cursor.execute('SELECT * FROM performance_metrics ORDER BY recorded_at DESC')
497497 metrics = [dict(row) for row in cursor.fetchall()]
498498 zip_file.writestr("performance_metrics.json", json.dumps(metrics, indent=2))
499499 except:
500500 pass
501-
501+
502502 # Export test sessions if available
503503 try:
504504 cursor.execute('SELECT * FROM test_sessions ORDER BY created_at DESC')
505505 sessions = [dict(row) for row in cursor.fetchall()]
506506 zip_file.writestr("test_sessions.json", json.dumps(sessions, indent=2))
507507 except:
508508 pass
509-
509+
510510 conn.close()
511-
511+
512512 # Add metadata
513513 metadata = {
514514 "export_timestamp": time.strftime('%Y-%m-%dT%H:%M:%S%z', time.gmtime()),
@@ -521,24 +521,24 @@ async def export_data():
521521 }
522522 }
523523 zip_file.writestr("metadata.json", json.dumps(metadata, indent=2))
524-
524+
525525 zip_buffer.seek(0)
526-
526+
527527 # Return as streaming response
528528 def iter_zip():
529529 yield zip_buffer.getvalue()
530-
530+
531531 timestamp = time.strftime('%Y%m%d_%H%M%S', time.gmtime())
532532 filename = f"mockloop_export_{timestamp}.zip"
533-
533+
534534 print(f"DEBUG ADMIN: Exported {len(logs_data)} logs to {filename}")
535-
535+
536536 return StreamingResponse(
537537 iter_zip(),
538538 media_type="application/zip",
539539 headers={"Content-Disposition": f"attachment; filename={filename}"}
540540 )
541-
541+
542542 except Exception as e:
543543 print(f"DEBUG ADMIN: Error exporting data: {e}")
544544 return {"error": str(e)}
@@ -549,11 +549,11 @@ async def get_request_logs(limit: int = 100, offset: int = 0):
549549 conn = sqlite3.connect(str(DB_PATH))
550550 conn.row_factory = sqlite3.Row
551551 cursor = conn.cursor()
552-
552+
553553 # Get total count
554554 cursor.execute("SELECT COUNT(*) FROM request_logs")
555555 total_count = cursor.fetchone()[0]
556-
556+
557557 # Get paginated logs with all available columns
558558 cursor.execute('''
559559 SELECT id, timestamp, type, method, path, status_code, process_time_ms,
@@ -564,7 +564,7 @@ async def get_request_logs(limit: int = 100, offset: int = 0):
564564 ORDER BY created_at DESC
565565 LIMIT ? OFFSET ?
566566 ''', (limit, offset))
567-
567+
568568 logs = []
569569 for row in cursor.fetchall():
570570 log_entry = {
@@ -590,11 +590,11 @@ async def get_request_logs(limit: int = 100, offset: int = 0):
590590 "created_at": row["created_at"]
591591 }
592592 logs.append(log_entry)
593-
593+
594594 conn.close()
595595 print(f"DEBUG ADMIN: Retrieved {len(logs)} logs from database (total: {total_count})")
596596 return {"logs": logs, "count": total_count}
597-
597+
598598 except Exception as e:
599599 print(f"DEBUG ADMIN: Error querying database: {e}")
600600 return {"logs": [], "count": 0, "error": str(e)}
@@ -605,27 +605,27 @@ async def get_debug_info():
605605 # Get database info
606606 conn = sqlite3.connect(str(DB_PATH))
607607 cursor = conn.cursor()
608-
608+
609609 # Check database tables and counts
610610 cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
611611 tables = [row[0] for row in cursor.fetchall()]
612-
612+
613613 table_info = {}
614614 for table in tables:
615615 cursor.execute(f"SELECT COUNT(*) FROM {table}")
616616 count = cursor.fetchone()[0]
617617 table_info[table] = count
618-
618+
619619 # Get recent logs count
620620 cursor.execute("SELECT COUNT(*) FROM request_logs WHERE created_at > datetime('now', '-1 hour')")
621621 recent_logs = cursor.fetchone()[0]
622-
622+
623623 # Get schema version
624624 cursor.execute("SELECT MAX(version) FROM schema_version")
625625 schema_version = cursor.fetchone()[0] or 0
626-
626+
627627 conn.close()
628-
628+
629629 debug_info = {
630630 "status": "ok",
631631 "database": {
@@ -641,13 +641,13 @@ async def get_debug_info():
641641 },
642642 "timestamp": time.strftime('%Y-%m-%dT%H:%M:%S%z', time.gmtime())
643643 }
644-
644+
645645 print(f"DEBUG ADMIN: Debug info retrieved successfully")
646646 return debug_info
647-
647+
648648 except Exception as e:
649649 print(f"DEBUG ADMIN: Error getting debug info: {e}")
650- return {"status": "error", "error": str(e)}"""
650+ return {"status": "error", "error": str(e)}""" # noqa: S608
651651 webhook_api_endpoints_str = ""
652652 if webhooks_enabled_bool and admin_ui_enabled_bool :
653653 _webhook_api_endpoints_raw = """
0 commit comments