feat: show last activity timestamp per device on Tuerschilder page

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 11:28:33 +02:00
co-authored by Claude Opus 4.6
parent ae6feacf6a
commit 77ae7b357d
2 changed files with 15 additions and 2 deletions
+12 -1
View File
@@ -202,9 +202,20 @@ async def toggle_user(azure_id: str):
@app.get("/devices", response_class=HTMLResponse)
async def devices_page(request: Request):
conn = database.get_db()
devices = conn.execute(
devices_raw = conn.execute(
"SELECT * FROM wled_devices ORDER BY name, hostname"
).fetchall()
# Letzte Aktivitaet pro Device aus activity_log
devices = []
for dev in devices_raw:
last_act = conn.execute("""
SELECT MAX(l.timestamp) as la
FROM activity_log l
WHERE l.wled_url LIKE '%' || ? || '%'
""", (dev["hostname"],)).fetchone()
d = dict(dev)
d["last_activity"] = last_act["la"] if last_act and last_act["la"] else None
devices.append(d)
last_check_row = conn.execute(
"SELECT MAX(last_check) as lc FROM wled_devices WHERE last_check IS NOT NULL"
).fetchone()