Skip to content
Snippets Groups Projects
Commit 2fc91bab authored by permcu's avatar permcu
Browse files

Properly prefetch and sort documentations

sorting happens in python now - since only this solution is compatible
with prefetch
parent 41f66b0d
No related branches found
No related tags found
1 merge request!422Resolve "Add export functionality to course book"
......@@ -242,9 +242,12 @@ def generate_full_register_printout(
if include_coursebook:
context["documentations_by_day"] = {}
documentations.prefetch_related("participations", "personal_notes")
for day in documentations.dates("datetime_start", "day"):
context["documentations_by_day"][day] = documentations.filter(datetime_start__date=day)
documentations = documentations.order_by("datetime_start").prefetch_related(
prefetch_notable_participations(select_related=["person"]),
prefetch_personal_notes("personal_notes", select_related=["person"])
)
for doc in documentations:
context["documentations_by_day"].setdefault(doc.datetime_start.date(), []).append(doc)
# OLD
......
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