From 0d2415aef2e937b4162fb5bfd2a37ec3dee3cd1e Mon Sep 17 00:00:00 2001 From: "Andreas (@xAndy) Zimmermann" Date: Sun, 28 May 2023 12:28:19 +0200 Subject: [PATCH] prefetch more data for team view --- shiftregister/team/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 9d76d8b..762a439 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -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()