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
05b034dd
Commit
05b034dd
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add some (convering) indexes to speed up database queries
parent
7206d283
No related branches found
No related tags found
1 merge request
!150
Resolve "Django 3.2 database improvements"
Pipeline
#6942
failed
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/chronos/migrations/0005_indexes.py
+59
-0
59 additions, 0 deletions
aleksis/apps/chronos/migrations/0005_indexes.py
aleksis/apps/chronos/models.py
+19
-2
19 additions, 2 deletions
aleksis/apps/chronos/models.py
with
78 additions
and
2 deletions
aleksis/apps/chronos/migrations/0005_indexes.py
0 → 100644
+
59
−
0
View file @
05b034dd
# Generated by Django 3.2 on 2021-04-08 19:12
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
core
'
,
'
0010_external_link_widget
'
),
(
'
chronos
'
,
'
0004_substitution_extra_lesson_year
'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'
chronosglobalpermissions
'
,
options
=
{
'
managed
'
:
False
,
'
permissions
'
:
((
'
view_all_timetables
'
,
'
Can view all timetables
'
),
(
'
view_timetable_overview
'
,
'
Can view timetable overview
'
),
(
'
view_lessons_day
'
,
'
Can view all lessons per day
'
))},
),
migrations
.
AlterModelOptions
(
name
=
'
lessonsubstitution
'
,
options
=
{
'
ordering
'
:
[
'
year
'
,
'
week
'
,
'
lesson_period__period__weekday
'
,
'
lesson_period__period__period
'
],
'
verbose_name
'
:
'
Lesson substitution
'
,
'
verbose_name_plural
'
:
'
Lesson substitutions
'
},
),
migrations
.
RemoveIndex
(
model_name
=
'
event
'
,
name
=
'
chronos_eve_period__c7ec33_idx
'
,
),
migrations
.
RemoveIndex
(
model_name
=
'
lessonperiod
'
,
name
=
'
chronos_les_lesson__05250e_idx
'
,
),
migrations
.
AddIndex
(
model_name
=
'
event
'
,
index
=
models
.
Index
(
fields
=
[
'
date_start
'
,
'
date_end
'
],
include
=
(
'
period_from
'
,
'
period_to
'
),
name
=
'
event_date_start_date_end
'
),
),
migrations
.
AddIndex
(
model_name
=
'
extralesson
'
,
index
=
models
.
Index
(
fields
=
[
'
week
'
,
'
year
'
],
name
=
'
extra_lesson_week_year
'
),
),
migrations
.
AddIndex
(
model_name
=
'
lessonperiod
'
,
index
=
models
.
Index
(
fields
=
[
'
lesson
'
,
'
period
'
],
name
=
'
lesson_period_lesson_period
'
),
),
migrations
.
AddIndex
(
model_name
=
'
lessonperiod
'
,
index
=
models
.
Index
(
fields
=
[
'
room
'
],
include
=
(
'
lesson
'
,
'
period
'
),
name
=
'
lesson_period_room
'
),
),
migrations
.
AddIndex
(
model_name
=
'
lessonsubstitution
'
,
index
=
models
.
Index
(
fields
=
[
'
week
'
,
'
year
'
],
name
=
'
substitution_week_year
'
),
),
migrations
.
AddIndex
(
model_name
=
'
lessonsubstitution
'
,
index
=
models
.
Index
(
fields
=
[
'
lesson_period
'
],
name
=
'
substitution_lesson_period
'
),
),
migrations
.
AddIndex
(
model_name
=
'
validityrange
'
,
index
=
models
.
Index
(
fields
=
[
'
date_start
'
,
'
date_end
'
],
name
=
'
validity_date_start_date_end
'
),
),
]
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/models.py
+
19
−
2
View file @
05b034dd
...
...
@@ -117,6 +117,9 @@ class ValidityRange(ExtensibleModel):
verbose_name
=
_
(
"
Validity range
"
)
verbose_name_plural
=
_
(
"
Validity ranges
"
)
unique_together
=
[
"
date_start
"
,
"
date_end
"
]
indexes
=
[
models
.
Index
(
fields
=
[
"
date_start
"
,
"
date_end
"
],
name
=
"
validity_date_start_date_end
"
)
]
class
TimePeriod
(
ValidityRangeRelatedExtensibleModel
):
...
...
@@ -425,6 +428,10 @@ class LessonSubstitution(ExtensibleModel, TeacherPropertiesMixin, WeekRelatedMix
name
=
"
either_substituted_or_cancelled
"
,
)
]
indexes
=
[
models
.
Index
(
fields
=
[
"
week
"
,
"
year
"
],
name
=
"
substitution_week_year
"
),
models
.
Index
(
fields
=
[
"
lesson_period
"
],
name
=
"
substitution_lesson_period
"
),
]
verbose_name
=
_
(
"
Lesson substitution
"
)
verbose_name_plural
=
_
(
"
Lesson substitutions
"
)
...
...
@@ -531,7 +538,10 @@ class LessonPeriod(WeekAnnotationMixin, TeacherPropertiesMixin, ExtensibleModel)
"
period__period
"
,
"
lesson__subject
"
,
]
indexes
=
[
models
.
Index
(
fields
=
[
"
lesson
"
,
"
period
"
])]
indexes
=
[
models
.
Index
(
fields
=
[
"
lesson
"
,
"
period
"
],
name
=
"
lesson_period_lesson_period
"
),
models
.
Index
(
fields
=
[
"
room
"
],
include
=
[
"
lesson
"
,
"
period
"
],
name
=
"
lesson_period_room
"
),
]
verbose_name
=
_
(
"
Lesson period
"
)
verbose_name_plural
=
_
(
"
Lesson periods
"
)
...
...
@@ -992,7 +1002,13 @@ class Event(SchoolTermRelatedExtensibleModel, GroupPropertiesMixin, TeacherPrope
class
Meta
:
ordering
=
[
"
date_start
"
]
indexes
=
[
models
.
Index
(
fields
=
[
"
period_from
"
,
"
period_to
"
,
"
date_start
"
,
"
date_end
"
])]
indexes
=
[
models
.
Index
(
fields
=
[
"
date_start
"
,
"
date_end
"
],
include
=
[
"
period_from
"
,
"
period_to
"
],
name
=
"
event_date_start_date_end
"
,
)
]
verbose_name
=
_
(
"
Event
"
)
verbose_name_plural
=
_
(
"
Events
"
)
...
...
@@ -1046,6 +1062,7 @@ class ExtraLesson(
class
Meta
:
verbose_name
=
_
(
"
Extra lesson
"
)
verbose_name_plural
=
_
(
"
Extra lessons
"
)
indexes
=
[
models
.
Index
(
fields
=
[
"
week
"
,
"
year
"
],
name
=
"
extra_lesson_week_year
"
)]
class
ChronosGlobalPermissions
(
GlobalPermissionModel
):
...
...
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