Fix metrics again

pull/1/head
Luca 2 years ago
parent 28c23f5782
commit 422d588d53

@ -5,6 +5,10 @@ from django.db import models
def metrics(request): def metrics(request):
worked_seconds_total = ShiftRegistration.objects.filter(
state=ShiftRegistration.RegState.CHECKED_IN
).aggregate(sum=Sum("shift__duration"))["sum"]
response = HttpResponse( response = HttpResponse(
"\n".join( "\n".join(
( (
@ -38,18 +42,16 @@ def metrics(request):
Message.objects.all().count(), Message.objects.all().count(),
), ),
( (
"worked_shifts_total", "worked_seconds_total",
ShiftRegistration.objects.filter( worked_seconds_total.total_seconds()
state=ShiftRegistration.RegState.CHECKED_IN if worked_seconds_total
).count(), else 0.0,
), ),
( (
"worked_seconds_total", "worked_shifts_total",
ShiftRegistration.objects.filter( ShiftRegistration.objects.filter(
state=ShiftRegistration.RegState.CHECKED_IN state=ShiftRegistration.RegState.CHECKED_IN
) ).count(),
.aggregate(sum=Sum("shift__duration"))["sum"]
.total_seconds(),
), ),
) )
) )

Loading…
Cancel
Save