From 3e691d774c6d2a1541026b9763a3a690d74f7c3e Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 4 Jan 2026 12:50:47 +0000 Subject: [PATCH] Refactor exam list annotation to use unfiltered counts for accurate overview matching --- generic/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generic/views.py b/generic/views.py index a956da04..5dcee7df 100644 --- a/generic/views.py +++ b/generic/views.py @@ -1922,10 +1922,11 @@ class ExamViews(View, LoginRequiredMixin): .order_by("name") ) - # Annotate counts for template usage so `.count()` is not called per-object + # Annotate counts for template usage so `.count()` is not called per-object. + # Use unfiltered counts to match the per-exam `exam_overview` counts. exam_list = exam_list.annotate( - valid_cid_users_count=Count("valid_cid_users", filter=Q(valid_cid_users__active=True)), - valid_user_users_count=Count("valid_user_users", filter=Q(valid_user_users__is_active=True)), + valid_cid_users_count=Count("valid_cid_users"), + valid_user_users_count=Count("valid_user_users"), ).select_related("examcollection").prefetch_related("author") if not all: