Skip to content
Snippets Groups Projects
Verified Commit eae1c27b authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Calculate statistics about participations with lesson events

parent 400f4934
No related branches found
No related tags found
1 merge request!476Resolve "Not storing groups for documentations is kind of a problem"
......@@ -2,6 +2,7 @@ from django.db.models import FilteredRelation, Q, QuerySet, Value
from django.db.models.aggregates import Count, Sum
from django.utils.translation import gettext as _
from aleksis.apps.chronos.models import LessonEvent
from aleksis.apps.kolego.models import AbsenceReason
from aleksis.core.models import Group, Person, SchoolTerm
......@@ -137,13 +138,6 @@ def annotate_person_statistics_for_school_term(
datetime_end__date__lte=school_term.date_end,
)
if group:
documentations = documentations.filter(
pk__in=Documentation.objects.filter(course__groups=group)
.values_list("pk", flat=True)
.union(
Documentation.objects.filter(course__groups__parent_groups=group).values_list(
"pk", flat=True
)
)
)
lesson_events = LessonEvent.objects.filter(LessonEvent.objects.for_group_q(group))
documentations = documentations.filter(amends__in=lesson_events)
return annotate_person_statistics_from_documentations(persons, documentations)
......@@ -7,6 +7,7 @@ from django.utils.translation import gettext as _
from celery.result import allow_join_result
from celery.states import SUCCESS
from aleksis.apps.chronos.models import LessonEvent
from aleksis.apps.cursus.models import Course
from aleksis.apps.kolego.models.absence import AbsenceReason
from aleksis.core.models import Group, PDFFile
......@@ -118,6 +119,13 @@ def generate_full_register_printout(
course__groups__parent_groups=group
).values_list("pk", flat=True)
)
.union(
Documentation.objects.filter(
amends__in=LessonEvent.objects.filter(
LessonEvent.objects.for_group_q(group)
)
).values_list("pk", flat=True)
)
)
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment