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

Use filter in favour of for loops

parent 8e6c9320
No related branches found
No related tags found
1 merge request!90Performance optimizations
...@@ -177,10 +177,14 @@ def get_lesson_documentation( ...@@ -177,10 +177,14 @@ def get_lesson_documentation(
if not week: if not week:
week = self.week week = self.week
# Use all to make effect of prefetched data # Use all to make effect of prefetched data
for documentation in self.documentations.all(): doc_filter = filter(
if documentation.week == week.week and documentation.year == week.year: lambda d: d.week == week.week and d.year == week.year,
return documentation self.dopycumentations.all(),
return None )
try:
return next(doc_filter)
except StopIteration:
return None
@LessonPeriod.method @LessonPeriod.method
......
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