Fix metrics again
This commit is contained in:
parent
28c23f5782
commit
422d588d53
|
@ -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(),
|
||||
),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue