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)