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
3e931079
Verified
Commit
3e931079
authored
4 months ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix queries for person statistics
parent
b14d34c2
No related branches found
No related tags found
1 merge request
!361
Resolve "Add statistics page for absences"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/model_extensions.py
+7
-5
7 additions, 5 deletions
aleksis/apps/alsijil/model_extensions.py
with
7 additions
and
5 deletions
aleksis/apps/alsijil/model_extensions.py
+
7
−
5
View file @
3e931079
from
django.utils.translation
import
gettext
as
_
from
django.db.models
import
FilteredRelation
,
Q
,
QuerySet
from
django.db.models.aggregates
import
Count
,
Sum
from
django.utils.translation
import
gettext
as
_
from
aleksis.apps.kolego.models
import
AbsenceReason
from
aleksis.core.models
import
Group
,
Person
,
SchoolTerm
...
...
@@ -34,7 +33,6 @@ Group.add_permission("assign_grouprole", _("Can assign a group role for this gro
Person
.
add_permission
(
"
register_absence_person
"
,
_
(
"
Can register an absence for a person
"
))
def
annotate_person_statistics
(
persons
:
QuerySet
[
Person
],
participations_filter
:
Q
,
personal_notes_filter
:
Q
)
->
QuerySet
[
Person
]:
...
...
@@ -59,7 +57,7 @@ def annotate_person_statistics(
filter
=
Q
(
filtered_participation_statuses__absence_reason__count_as_absent
=
True
),
distinct
=
True
,
),
tardiness_sum
=
Sum
(
"
filtered_participation_statuses__tardiness
"
),
tardiness_sum
=
Sum
(
"
filtered_participation_statuses__tardiness
"
,
distinct
=
True
),
tardiness_count
=
Count
(
"
filtered_participation_statuses
"
,
filter
=
Q
(
filtered_participation_statuses__tardiness__gt
=
0
),
...
...
@@ -104,7 +102,11 @@ def annotate_person_statistics_for_school_term(
datetime_end__date__lte
=
school_term
.
date_end
,
)
if
group
:
documentations
.
filter
(
Q
(
course__groups
=
group
)
|
Q
(
course__groups__parent_groups
=
group
))
documentations
.
filter
(
pk__in
=
Documentation
.
objects
.
filter
(
course__groups
=
group
).
union
(
Documentation
.
objects
.
filter
(
course__groups__parent_groups
=
group
)
)
)
docs
=
list
(
documentations
.
values_list
(
"
pk
"
,
flat
=
True
))
return
annotate_person_statistics
(
persons
,
...
...
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