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
a4b9dfea
Verified
Commit
a4b9dfea
authored
1 month ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Improve statistics builder
parent
6978f1c5
No related branches found
No related tags found
1 merge request
!477
Resolve "Add export functionality to absence statistics page"
Pipeline
#195684
failed
1 month ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Stage: docker
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/alsijil/tasks.py
+3
-5
3 additions, 5 deletions
aleksis/apps/alsijil/tasks.py
aleksis/apps/alsijil/util/statistics.py
+3
-3
3 additions, 3 deletions
aleksis/apps/alsijil/util/statistics.py
with
6 additions
and
8 deletions
aleksis/apps/alsijil/tasks.py
+
3
−
5
View file @
a4b9dfea
...
...
@@ -163,11 +163,9 @@ def generate_person_register_printout(
doc_query_set
=
Documentation
.
objects
.
select_related
(
"
subject
"
).
prefetch_related
(
"
teachers
"
)
statistics
=
(
(
StatisticsBuilder
(
Person
.
objects
.
filter
(
id
=
person
.
id
))
.
use_from_school_term
(
school_term
)
.
annotate_statistics
()
)
StatisticsBuilder
(
Person
.
objects
.
filter
(
id
=
person
.
id
))
.
use_from_school_term
(
school_term
)
.
annotate_statistics
()
.
prefetch_relevant_participations
(
documentation_with_details
=
doc_query_set
)
.
prefetch_relevant_personal_notes
(
documentation_with_details
=
doc_query_set
)
.
build
()
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/util/statistics.py
+
3
−
3
View file @
a4b9dfea
...
...
@@ -17,7 +17,7 @@ class BuilderError(Exception):
class
StatisticsBuilder
:
"""
Builder class for building queries with annotated statistics on persons.
To build queries, you can combine
one
`use_` with multiple `annotate` or `prefetch`
To build queries, you can combine `use_` with multiple `annotate` or `prefetch`
methods. At the end, call `build` to get the actual queryset.
>>>
StatisticsBuilder
(
person_qs
).
use_from_school_term
(
school_term
).
annotate_statistics
().
build
()
...
...
@@ -87,7 +87,7 @@ class StatisticsBuilder:
def
_annotate_filtered_participations
(
self
,
condition
:
Q
|
None
=
None
)
->
"
StatisticsBuilder
"
:
"""
Annotate a filtered relation for participations.
"""
if
not
self
.
participations_filter
and
not
condition
:
raise
BuilderError
raise
BuilderError
(
"
Annotation of participations needs a participation filter.
"
)
self
.
qs
=
self
.
qs
.
annotate
(
filtered_participation_statuses
=
FilteredRelation
(
"
participations
"
,
...
...
@@ -99,7 +99,7 @@ class StatisticsBuilder:
def
_annotate_filtered_personal_notes
(
self
,
condition
:
Q
|
None
=
None
)
->
"
StatisticsBuilder
"
:
"""
Annotate a filtered relation for personal notes.
"""
if
not
self
.
personal_notes_filter
and
not
condition
:
raise
BuilderError
raise
BuilderError
(
"
Annotation of personal notes needs a participation filter.
"
)
self
.
qs
=
self
.
qs
.
annotate
(
filtered_personal_notes
=
FilteredRelation
(
"
new_personal_notes
"
,
...
...
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