Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Chronos
Merge requests
!83
Minimize query count
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Minimize query count
feature/performance-optimizations
into
master
Overview
0
Commits
8
Pipelines
4
Changes
2
Merged
Jonathan Weth
requested to merge
feature/performance-optimizations
into
master
4 years ago
Overview
0
Commits
8
Pipelines
4
Changes
2
Expand
Close
#79 (closed)
Edited
4 years ago
by
Jonathan Weth
0
0
Merge request reports
Viewing commit
93cedb72
Prev
Next
Show latest version
2 files
+
95
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
Verified
93cedb72
Add managers with select_related and prefetch_related, also add memoize for some often used methods
· 93cedb72
Jonathan Weth
authored
4 years ago
aleksis/apps/chronos/managers.py
+
80
−
1
Options
@@ -112,11 +112,90 @@ class LessonSubstitutionManager(CurrentSiteManager):
.
select_related
(
"
lesson_period
"
,
"
lesson_period__lesson
"
,
"
lesson_period__lesson__subject
"
,
"
subject
"
,
"
lesson_period__period
"
,
"
room
"
,
"
lesson_period__room
"
,
)
.
prefetch_related
(
"
lesson_period__lesson__groups
"
,
"
lesson_period__lesson__groups__parent_groups
"
,
"
teachers
"
,
"
lesson_period__lesson__teachers
"
,
)
)
class
SupervisionManager
(
CurrentSiteManager
):
"""
Manager adding specific methods to supervisions.
"""
def
get_queryset
(
self
):
"""
Ensure all related data is loaded as well.
"""
return
(
super
()
.
get_queryset
()
.
select_related
(
"
teacher
"
,
"
area
"
,
"
break_item
"
,
"
break_item__after_period
"
,
"
break_item__before_period
"
,
)
)
class
SupervisionSubstitutionManager
(
CurrentSiteManager
):
"""
Manager adding specific methods to supervision substitutions.
"""
def
get_queryset
(
self
):
"""
Ensure all related data is loaded as well.
"""
return
(
super
()
.
get_queryset
()
.
select_related
(
"
teacher
"
,
"
supervision
"
,
"
supervision__teacher
"
,
"
supervision__area
"
,
"
supervision__break_item
"
,
"
supervision__break_item__after_period
"
,
"
supervision__break_item__before_period
"
,
)
)
class
EventManager
(
CurrentSiteManager
):
"""
Manager adding specific methods to events.
"""
def
get_queryset
(
self
):
"""
Ensure all related data is loaded as well.
"""
return
(
super
()
.
get_queryset
()
.
select_related
(
"
period_from
"
,
"
period_to
"
)
.
prefetch_related
(
"
groups
"
,
"
groups__school_term
"
,
"
groups__parent_groups
"
,
"
teachers
"
,
"
rooms
"
,
)
)
class
ExtraLessonManager
(
CurrentSiteManager
):
"""
Manager adding specific methods to extra lessons.
"""
def
get_queryset
(
self
):
"""
Ensure all related data is loaded as well.
"""
return
(
super
()
.
get_queryset
()
.
select_related
(
"
room
"
,
"
period
"
,
"
subject
"
)
.
prefetch_related
(
"
groups
"
,
"
groups__school_term
"
,
"
groups__parent_groups
"
,
"
teachers
"
,
)
.
prefetch_related
(
"
lesson_period__lesson__groups
"
,
"
teachers
"
)
)
Loading