Refactor exam list annotation to use unfiltered counts for accurate overview matching
This commit is contained in:
+4
-3
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user