2
0
Fork 0

prefetch more data for team view

This commit is contained in:
Andreas (@xAndy) Zimmermann 2023-05-28 12:28:19 +02:00
parent 7aa5da28fe
commit 0d2415aef2
1 changed files with 3 additions and 0 deletions

View File

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