|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
from django.db import models
|
|
|
|
|
from django.db.models import Count, Case, F, When, Sum
|
|
|
|
|
from django.db.models.functions import Coalesce
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
|
from shiftregister.app.models import Helper, Shift, ShiftRegistration, Message
|
|
|
|
|
|
|
|
|
@ -42,8 +41,11 @@ def metrics(request):
|
|
|
|
|
"helpers_required_total",
|
|
|
|
|
Shift.objects.filter(deleted=False)
|
|
|
|
|
.annotate(
|
|
|
|
|
real_required_helpers=Coalesce(
|
|
|
|
|
F("required_helpers"), F("room__required_helpers")
|
|
|
|
|
real_required_helpers=Case(
|
|
|
|
|
When(
|
|
|
|
|
required_helpers=0, then=F("room__required_helpers")
|
|
|
|
|
),
|
|
|
|
|
default=F("required_helpers"),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.aggregate(sum=Sum("real_required_helpers"))["sum"],
|
|
|
|
|