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
c83ec781
Commit
c83ec781
authored
4 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Plain Diff
Merge branch '75-absence-values-get-multiplied' into 'master'
Resolve "Fix aggregation of absences and tardninesses" Closes
#75
See merge request
!52
parents
c940fbce
add5ccd7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!52
Resolve "Fix aggregation of absences and tardninesses"
Pipeline
#2754
passed
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/views.py
+16
-12
16 additions, 12 deletions
aleksis/apps/alsijil/views.py
with
16 additions
and
12 deletions
aleksis/apps/alsijil/views.py
+
16
−
12
View file @
c83ec781
...
...
@@ -4,7 +4,7 @@ from typing import Optional
from
aleksis.apps.chronos.managers
import
TimetableType
from
aleksis.apps.chronos.util.chronos_helpers
import
get_el_by_pk
from
django.core.exceptions
import
PermissionDenied
from
django.db.models
import
Count
,
Exists
,
OuterRef
,
Q
,
Sum
from
django.db.models
import
Count
,
Exists
,
F
,
OuterRef
,
Q
,
Subquery
,
Sum
from
django.http
import
Http404
,
HttpRequest
,
HttpResponse
,
HttpResponseNotFound
from
django.shortcuts
import
get_object_or_404
,
redirect
,
render
from
django.urls
import
reverse
...
...
@@ -166,36 +166,40 @@ def week_view(
if
lesson_periods
:
# Aggregate all personal notes for this group and week
lesson_periods_pk
=
lesson_periods
.
values_list
(
"
pk
"
,
flat
=
True
)
persons
=
(
Person
.
objects
.
filter
(
is_active
=
True
)
.
filter
(
member_of__lessons__lesson_periods__in
=
lesson_periods
_pk
)
.
filter
(
member_of__lessons__lesson_periods__in
=
lesson_periods
)
.
distinct
()
.
prefetch_related
(
"
personal_notes
"
)
.
annotate
(
absences_count
=
Count
(
"
personal_notes
__absent
"
,
"
personal_notes
"
,
filter
=
Q
(
personal_notes__lesson_period__in
=
lesson_periods
_pk
,
personal_notes__lesson_period__in
=
lesson_periods
,
personal_notes__week
=
wanted_week
.
week
,
personal_notes__absent
=
True
,
),
distinct
=
True
,
),
unexcused_count
=
Count
(
"
personal_notes
__absent
"
,
"
personal_notes
"
,
filter
=
Q
(
personal_notes__lesson_period__in
=
lesson_periods
_pk
,
personal_notes__lesson_period__in
=
lesson_periods
,
personal_notes__week
=
wanted_week
.
week
,
personal_notes__absent
=
True
,
personal_notes__excused
=
False
,
),
distinct
=
True
,
),
tardiness_sum
=
Su
m
(
"
p
erson
al_notes__late
"
,
filter
=
Q
(
personal_notes__lesson_period__in
=
lesson_periods
_pk
,
tardiness_sum
=
Su
bquery
(
P
erson
.
objects
.
filter
(
pk
=
OuterRef
(
"
pk
"
),
personal_notes__lesson_period__in
=
lesson_periods
,
personal_notes__week
=
wanted_week
.
week
,
),
)
.
distinct
()
.
annotate
(
tardiness_sum
=
Sum
(
"
personal_notes__late
"
))
.
values
(
"
tardiness_sum
"
)
),
)
)
...
...
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