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
6a1f542b
Prev
Next
Show latest version
2 files
+
8
−
2
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
6a1f542b
Add prefetch option for get_el_by_pk
· 6a1f542b
Jonathan Weth
authored
4 years ago
aleksis/apps/chronos/util/chronos_helpers.py
+
7
−
1
Options
@@ -16,9 +16,15 @@ def get_el_by_pk(
year
:
Optional
[
int
]
=
None
,
week
:
Optional
[
int
]
=
None
,
regular
:
Optional
[
str
]
=
None
,
prefetch
:
bool
=
False
,
):
if
type_
==
TimetableType
.
GROUP
.
value
:
return
get_object_or_404
(
Group
,
pk
=
pk
)
return
get_object_or_404
(
Group
.
objects
.
prefetch_related
(
"
owners
"
,
"
parent_groups
"
)
if
prefetch
else
Group
,
pk
=
pk
,
)
elif
type_
==
TimetableType
.
TEACHER
.
value
:
return
get_object_or_404
(
Person
,
pk
=
pk
)
elif
type_
==
TimetableType
.
ROOM
.
value
:
Loading