Spaces:
Running
Running
Update admin_routes.py
Browse files- admin_routes.py +9 -7
admin_routes.py
CHANGED
@@ -3,7 +3,7 @@ Flare Admin API Routes
|
|
3 |
~~~~~~~~~~~~~~~~~~~~~
|
4 |
Admin UI için gerekli tüm endpoint'ler
|
5 |
"""
|
6 |
-
|
7 |
import os
|
8 |
import json
|
9 |
import hashlib
|
@@ -24,8 +24,9 @@ from config_provider import ConfigProvider
|
|
24 |
ACTIVITY_LOG_RETENTION_DAYS = 30
|
25 |
ACTIVITY_LOG_MAX_ENTRIES = 10000
|
26 |
|
27 |
-
|
28 |
-
|
|
|
29 |
while True:
|
30 |
try:
|
31 |
config = load_config()
|
@@ -37,8 +38,8 @@ async def cleanup_activity_log():
|
|
37 |
# Filter recent entries
|
38 |
original_count = len(config["activity_log"])
|
39 |
config["activity_log"] = [
|
40 |
-
|
41 |
-
if datetime.fromisoformat(
|
42 |
]
|
43 |
|
44 |
# Also limit by max entries
|
@@ -55,11 +56,12 @@ async def cleanup_activity_log():
|
|
55 |
log(f"❌ Activity log cleanup error: {e}")
|
56 |
|
57 |
# Run cleanup once per day
|
58 |
-
|
59 |
|
60 |
# Start cleanup task when module loads
|
61 |
def start_cleanup_task():
|
62 |
-
|
|
|
63 |
|
64 |
# ===================== Dynamic Config Loading =====================
|
65 |
def get_jwt_config():
|
|
|
3 |
~~~~~~~~~~~~~~~~~~~~~
|
4 |
Admin UI için gerekli tüm endpoint'ler
|
5 |
"""
|
6 |
+
import threading
|
7 |
import os
|
8 |
import json
|
9 |
import hashlib
|
|
|
24 |
ACTIVITY_LOG_RETENTION_DAYS = 30
|
25 |
ACTIVITY_LOG_MAX_ENTRIES = 10000
|
26 |
|
27 |
+
# Activity log cleanup fonksiyonunu thread-safe yap
|
28 |
+
def cleanup_activity_log():
|
29 |
+
"""Cleanup old activity log entries - runs in background thread"""
|
30 |
while True:
|
31 |
try:
|
32 |
config = load_config()
|
|
|
38 |
# Filter recent entries
|
39 |
original_count = len(config["activity_log"])
|
40 |
config["activity_log"] = [
|
41 |
+
log_entry for log_entry in config["activity_log"]
|
42 |
+
if datetime.fromisoformat(log_entry["timestamp"].replace("Z", "+00:00")) > cutoff_date
|
43 |
]
|
44 |
|
45 |
# Also limit by max entries
|
|
|
56 |
log(f"❌ Activity log cleanup error: {e}")
|
57 |
|
58 |
# Run cleanup once per day
|
59 |
+
time.sleep(86400) # 24 hours
|
60 |
|
61 |
# Start cleanup task when module loads
|
62 |
def start_cleanup_task():
|
63 |
+
thread = threading.Thread(target=cleanup_activity_log, daemon=True)
|
64 |
+
thread.start()
|
65 |
|
66 |
# ===================== Dynamic Config Loading =====================
|
67 |
def get_jwt_config():
|