From 01d64f2d0929671b62e736263a417627bc46d34b Mon Sep 17 00:00:00 2001 From: Jonas Dittrich Date: Mon, 13 Apr 2026 21:04:12 +0200 Subject: [PATCH] prefetch participant and voter counts in contributor index --- evap/contributor/views.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/evap/contributor/views.py b/evap/contributor/views.py index 9fcac49b35..974cd0d201 100644 --- a/evap/contributor/views.py +++ b/evap/contributor/views.py @@ -58,7 +58,7 @@ def index(request): ) own_evaluations = ( - Evaluation.objects.filter(course__in=own_courses) + Evaluation.annotate_with_participant_and_voter_counts(Evaluation.objects.filter(course__in=own_courses)) .annotate(contributes_to=Exists(Evaluation.objects.filter(id=OuterRef("id"), contributions__contributor=user))) .prefetch_related("course", "course__evaluations", "course__programs", "course__type", "course__semester") ) @@ -77,9 +77,17 @@ def index(request): ) ) ) - delegated_evaluations = Evaluation.objects.filter(course__in=delegated_courses).prefetch_related( - "course", "course__evaluations", "course__programs", "course__type", "course__semester" + delegated_evaluations = Evaluation.annotate_with_participant_and_voter_counts( + Evaluation.objects.filter(course__in=delegated_courses) + ).prefetch_related( + "course", + "course__evaluations", + "course__programs", + "course__type", + "course__semester", + "course__responsibles", ) + delegated_evaluations = [evaluation for evaluation in delegated_evaluations if evaluation.can_be_seen_by(user)] for evaluation in delegated_evaluations: evaluation.delegated_evaluation = True