diff --git a/aleksis/apps/alsijil/model_extensions.py b/aleksis/apps/alsijil/model_extensions.py index 820770d630ee50daa62c6419e7ba774522e601b4..a43e54b952f13525b80dd51fe0c6f96bcf5d93de 100644 --- a/aleksis/apps/alsijil/model_extensions.py +++ b/aleksis/apps/alsijil/model_extensions.py @@ -93,9 +93,12 @@ def annotate_person_statistics( return persons -def annotate_person_statistics_from_documentations(docs: QuerySet[Documentation]) -> QuerySet[Person]: +def annotate_person_statistics_from_documentations( + persons: QuerySet[Person], + docs: QuerySet[Documentation] +) -> QuerySet[Person]: """Annotate a queryset of persons with class register statistics from queryset of documentations.""" - docs = list(documentations.values_list("pk", flat=True)) + docs = list(docs.values_list("pk", flat=True)) return annotate_person_statistics( persons, Q(participations__related_documentation__in=docs), @@ -113,4 +116,4 @@ def annotate_person_statistics_for_school_term( ) if group: documentations.filter(Q(course__groups=group) | Q(course__groups__parent_groups=group)) - return annotate_person_statistics_from_documentations(documentations) + return annotate_person_statistics_from_documentations(persons, documentations) diff --git a/aleksis/apps/alsijil/tasks.py b/aleksis/apps/alsijil/tasks.py index bd6c910635522ec586729b8d26832c22f7891b0d..ad62bdf24d215e29acbc67099addea22733786f2 100644 --- a/aleksis/apps/alsijil/tasks.py +++ b/aleksis/apps/alsijil/tasks.py @@ -98,7 +98,7 @@ def generate_full_register_printout( ) if include_members_table or include_person_overviews: - context["members"] = annotate_person_statistics_from_documentations(documentations) + context["members"] = annotate_person_statistics_from_documentations(group.members.all(), documentations) if include_person_overviews: doc_query_set = Documentation.objects.select_related("subject").prefetch_related("teachers"),