Add 'helpers_required_total' metric
This commit is contained in:
parent
a34f568083
commit
36cc1a5fec
|
@ -1,7 +1,8 @@
|
|||
from django.http import HttpResponse
|
||||
from shiftregister.app.models import Helper, ShiftRegistration, Message
|
||||
from django.db.models import Count, Case, When, Sum
|
||||
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
|
||||
|
||||
|
||||
def metrics(request):
|
||||
|
@ -37,6 +38,16 @@ def metrics(request):
|
|||
.filter(number_validated=True, shift_count__gte=1)
|
||||
.count(),
|
||||
),
|
||||
(
|
||||
"helpers_required_total",
|
||||
Shift.objects.filter(deleted=False)
|
||||
.annotate(
|
||||
real_required_helpers=Coalesce(
|
||||
F("required_helpers"), F("room__required_helpers")
|
||||
)
|
||||
)
|
||||
.aggregate(sum=Sum("real_required_helpers"))["sum"],
|
||||
),
|
||||
(
|
||||
"messages_sent_total",
|
||||
Message.objects.all().count(),
|
||||
|
|
Loading…
Reference in New Issue