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
Commits
2aa06cf2
Verified
Commit
2aa06cf2
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add BreakManager for prefetching
parent
6a1f542b
No related branches found
No related tags found
1 merge request
!83
Minimize query count
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/chronos/managers.py
+8
-0
8 additions, 0 deletions
aleksis/apps/chronos/managers.py
aleksis/apps/chronos/models.py
+3
-0
3 additions, 0 deletions
aleksis/apps/chronos/models.py
with
11 additions
and
0 deletions
aleksis/apps/chronos/managers.py
+
8
−
0
View file @
2aa06cf2
...
...
@@ -199,6 +199,14 @@ class ExtraLessonManager(CurrentSiteManager):
)
class
BreakManager
(
CurrentSiteManager
):
"""
Manager adding specific methods to breaks.
"""
def
get_queryset
(
self
):
"""
Ensure all related data is loaded as well.
"""
return
super
().
get_queryset
().
select_related
(
"
before_period
"
,
"
after_period
"
)
class
WeekQuerySetMixin
:
def
annotate_week
(
self
,
week
:
Union
[
CalendarWeek
]):
"""
Annotate all lessons in the QuerySet with the number of the provided calendar week.
"""
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/models.py
+
3
−
0
View file @
2aa06cf2
...
...
@@ -23,6 +23,7 @@ from django_global_request.middleware import get_request
from
aleksis.apps.chronos.managers
import
(
AbsenceQuerySet
,
BreakManager
,
CurrentSiteManager
,
EventQuerySet
,
ExtraLessonQuerySet
,
...
...
@@ -750,6 +751,8 @@ class SupervisionArea(ExtensibleModel):
class
Break
(
ValidityRangeRelatedExtensibleModel
):
objects
=
BreakManager
()
short_name
=
models
.
CharField
(
verbose_name
=
_
(
"
Short name
"
),
max_length
=
255
)
name
=
models
.
CharField
(
verbose_name
=
_
(
"
Long name
"
),
max_length
=
255
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment