refactor: 🎨 update dashboard activity data structure to use timestamps and add local hour bucketing

This commit is contained in:
2026-07-21 11:05:17 +01:00
parent 5b606404fc
commit 1b3404155c
4 changed files with 21 additions and 9 deletions
+7 -7
View File
@@ -2925,14 +2925,14 @@ def api_dashboard():
})
cursor.execute('''
SELECT HOUR(timestamp) AS hour, COUNT(*) AS count
FROM AuditLog
WHERE timestamp >= DATE_SUB(NOW(), INTERVAL 24 HOUR)
GROUP BY HOUR(timestamp)
ORDER BY hour
SELECT timestamp FROM AuditLog
WHERE timestamp >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 24 HOUR)
''')
activity_by_hour = {row['hour']: row['count'] for row in cursor.fetchall()}
activity = [{'hour': h, 'count': activity_by_hour.get(h, 0)} for h in range(24)]
activity = [
row['timestamp'].strftime('%Y-%m-%d %H:%M:%S')
if hasattr(row['timestamp'], 'strftime') else str(row['timestamp'])
for row in cursor.fetchall()
]
return jsonify({
'stats': {