Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Alsijil
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-Alsijil
Commits
e208d546
Verified
Commit
e208d546
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Make holiday data checks much more efficient by using SQL functions
parent
96c09d5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!92
Resolve "Add task for checking plausibility of data"
Pipeline
#5110
failed
4 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/data_checks.py
+30
-17
30 additions, 17 deletions
aleksis/apps/alsijil/data_checks.py
with
30 additions
and
17 deletions
aleksis/apps/alsijil/data_checks.py
+
30
−
17
View file @
e208d546
import
logging
from
django.db.models
import
F
from
django.db.models.expressions
import
ExpressionWrapper
,
Func
,
Value
from
django.db.models.fields
import
DateField
from
django.db.models.functions
import
Concat
from
django.db.models.query_utils
import
Q
from
django.utils.translation
import
gettext
as
_
from
aleksis.apps.chronos.util.date
import
week_weekday_to_date
from
aleksis.core.data_checks
import
DataCheck
,
IgnoreSolveOption
,
SolveOption
...
...
@@ -86,6 +88,15 @@ class NoGroupsOfPersonsSetInPersonalNotesDataCheck(DataCheck):
cls
.
register_result
(
note
)
weekday_to_date
=
ExpressionWrapper
(
Func
(
Concat
(
F
(
"
year
"
),
F
(
"
week
"
)),
Value
(
"
IYYYIW
"
),
output_field
=
DateField
(),
function
=
"
TO_DATE
"
)
+
F
(
"
lesson_period__period__weekday
"
),
output_field
=
DateField
(),
)
class
LessonDocumentationOnHolidaysDataCheck
(
DataCheck
):
"""
Checks for lesson documentation objects on holidays.
...
...
@@ -106,17 +117,18 @@ class LessonDocumentationOnHolidaysDataCheck(DataCheck):
from
.models
import
LessonDocumentation
holidays
=
list
(
Holiday
.
objects
.
all
()
)
holidays
=
Holiday
.
objects
.
all
()
documentations
=
LessonDocumentation
.
objects
.
filter
(
~
Q
(
topic
=
""
)
|
~
Q
(
group_note
=
""
)
|
~
Q
(
homework
=
""
)
)
for
doc
in
documentations
:
logging
.
info
(
f
"
Check lesson documentation
{
doc
}
"
)
day
=
week_weekday_to_date
(
doc
.
calendar_week
,
doc
.
lesson_period
.
period
.
weekday
)
if
len
(
list
(
filter
(
lambda
h
:
h
.
date_start
<=
day
<=
h
.
date_end
,
holidays
)))
>
0
:
logging
.
info
(
"
... on holidays
"
)
).
annotate
(
actual_date
=
weekday_to_date
)
for
holiday
in
holidays
:
docs_filtered_by_date
=
documentations
.
filter
(
actual_date__gte
=
holiday
.
date_start
,
actual_date__lte
=
holiday
.
date_end
)
for
doc
in
docs_filtered_by_date
:
logging
.
info
(
f
"
Lesson documentation
{
doc
}
is on holidays
"
)
cls
.
register_result
(
doc
)
...
...
@@ -140,17 +152,18 @@ class PersonalNoteOnHolidaysDataCheck(DataCheck):
from
.models
import
PersonalNote
holidays
=
list
(
Holiday
.
objects
.
all
()
)
holidays
=
Holiday
.
objects
.
all
()
personal_notes
=
PersonalNote
.
objects
.
filter
(
~
Q
(
remarks
=
""
)
|
Q
(
absent
=
True
)
|
~
Q
(
late
=
0
)
|
Q
(
extra_marks__isnull
=
False
)
)
for
note
in
personal_notes
:
logging
.
info
(
f
"
Check personal note
{
note
}
"
)
day
=
week_weekday_to_date
(
note
.
calendar_week
,
note
.
lesson_period
.
period
.
weekday
)
if
len
(
list
(
filter
(
lambda
h
:
h
.
date_start
<=
day
<=
h
.
date_end
,
holidays
)))
>
0
:
logging
.
info
(
"
... on holidays
"
)
).
annotate
(
actual_date
=
weekday_to_date
)
for
holiday
in
holidays
:
notes_filtered_by_date
=
personal_notes
.
filter
(
actual_date__gte
=
holiday
.
date_start
,
actual_date__lte
=
holiday
.
date_end
)
for
note
in
notes_filtered_by_date
:
logging
.
info
(
f
"
Personal note
{
note
}
is on holidays
"
)
cls
.
register_result
(
note
)
...
...
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