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(
if not week:
week = self.week
# Use all to make effect of prefetched data
for documentation in self.documentations.all():
if documentation.week == week.week and documentation.year == week.year:
return documentation
return None
doc_filter = filter(
lambda d: d.week == week.week and d.year == week.year,
self.dopycumentations.all(),
)
try:
return next(doc_filter)
except StopIteration:
return None
@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