From 4f9f357f9cb168fa6683d6bfeb78b0b44d4a62f8 Mon Sep 17 00:00:00 2001 From: Samuel Zielke Date: Sat, 3 Oct 2026 19:05:43 +0200 Subject: [PATCH] =?UTF-8?q?Dashboard:=20Verbindungen=20insgesamt=20getrenn?= =?UTF-8?q?t=20von=20eindeutigen=20Ger=C3=A4ten,=20Ger=C3=A4te-=C3=9Cbersi?= =?UTF-8?q?cht=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01M8BG6rcfV94au1CrMNQq9E --- app/templates/app/dashboard.html | 59 ++++++++++++++++++++++++++------ app/views.py | 13 ++++++- 2 files changed, 61 insertions(+), 11 deletions(-) diff --git a/app/templates/app/dashboard.html b/app/templates/app/dashboard.html index a5f71bc..cdd47b7 100644 --- a/app/templates/app/dashboard.html +++ b/app/templates/app/dashboard.html @@ -42,30 +42,39 @@
-
+
+
+
{{ total_connections }}
+
Verbindungen insgesamt (alle Pings)
+
+
+
+
+
{{ unique_devices_total }}
+
Geräte insgesamt (eindeutig)
+
+
+
+ +
+
{{ devices_today }}
Geräte heute
-
+
{{ devices_7d }}
Geräte (7 Tage)
-
+
{{ devices_30d }}
Geräte (30 Tage)
-
-
-
{{ unique_devices_total }}
-
Geräte insgesamt
-
-
@@ -107,8 +116,38 @@

+
+
Geräte-Übersicht (ein Eintrag pro Gerät, nicht pro Ping)
+
+ + + + + + + + + + + + {% for device in device_summary %} + + + + + + + + {% empty %} + + {% endfor %} + +
GerätPingsErster KontaktLetzter KontaktStandalone
{{ device.device_id|slice:":8" }}…{{ device.ping_count }}{{ device.first_seen|date:"d.m.Y H:i" }}{{ device.last_seen|date:"d.m.Y H:i" }}{{ device.standalone_any|yesno:"Ja,Nein" }}
Noch keine Daten
+
+
+
-
Letzte Signale
+
Letzte Signale (roher Ping-Log, ein Gerät kann hier mehrfach auftauchen)
diff --git a/app/views.py b/app/views.py index 79155e1..ca827c2 100644 --- a/app/views.py +++ b/app/views.py @@ -1,7 +1,7 @@ import json from django.contrib.admin.views.decorators import staff_member_required -from django.db.models import Count +from django.db.models import Count, Max, Min from django.http import JsonResponse from django.shortcuts import render, HttpResponse, redirect from django.utils import timezone @@ -102,6 +102,7 @@ def usage_dashboard(request): events = UsageEvent.objects.all() context = { + "total_connections": events.count(), "unique_devices_total": events.values("device_id").distinct().count(), "devices_today": events.filter(created_at__gte=today_start).values("device_id").distinct().count(), "devices_7d": events.filter(created_at__gte=now - timedelta(days=7)).values("device_id").distinct().count(), @@ -109,6 +110,16 @@ def usage_dashboard(request): "standalone_count": events.filter(is_standalone=True).values("device_id").distinct().count(), "by_platform": events.values("platform").annotate(count=Count("device_id", distinct=True)).order_by("-count"), "by_browser": events.values("browser").annotate(count=Count("device_id", distinct=True)).order_by("-count"), + "device_summary": ( + events.values("device_id") + .annotate( + ping_count=Count("id"), + first_seen=Min("created_at"), + last_seen=Max("created_at"), + standalone_any=Max("is_standalone"), + ) + .order_by("-last_seen") + ), "recent_events": events[:30], } return render(request, "app/dashboard.html", context)