2
0
Fork 0

Fix metrics again

This commit is contained in:
Luca 2023-05-08 00:16:17 +02:00
parent 28c23f5782
commit 422d588d53
1 changed files with 10 additions and 8 deletions

View File

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