prefetch more data for team view

pull/1/head
parent 7aa5da28fe
commit 0d2415aef2

@ -43,6 +43,7 @@ def shift_overview(request):
context = {} context = {}
context["running_shifts"] = ( context["running_shifts"] = (
Shift.with_reg_count() Shift.with_reg_count()
.prefetch_related("event__calendar")
.annotate( .annotate(
checkin_count=Count( checkin_count=Count(
Case( Case(
@ -63,6 +64,7 @@ def shift_overview(request):
context["next_shifts"] = ( context["next_shifts"] = (
Shift.with_reg_count() Shift.with_reg_count()
.prefetch_related("event__calendar")
.annotate(checkin_count=checkin_count) .annotate(checkin_count=checkin_count)
.filter( .filter(
start_at__gt=timezone.now(), start_at__gt=timezone.now(),
@ -77,6 +79,7 @@ def shift_overview(request):
lambda x: x is not None, lambda x: x is not None,
( (
Shift.with_reg_count() Shift.with_reg_count()
.prefetch_related("event__calendar")
.filter(room=room, start_at__gt=timezone.now(), deleted=False) .filter(room=room, start_at__gt=timezone.now(), deleted=False)
.order_by("start_at") .order_by("start_at")
.first() .first()

Loading…
Cancel
Save