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
02704e20
Verified
Commit
02704e20
authored
6 months ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Optimize some queries
parent
f1080b99
No related branches found
No related tags found
1 merge request
!433
Optimize some queries
Pipeline
#193717
failed
6 months 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/models.py
+5
-3
5 additions, 3 deletions
aleksis/apps/alsijil/models.py
aleksis/apps/alsijil/schema/__init__.py
+31
-16
31 additions, 16 deletions
aleksis/apps/alsijil/schema/__init__.py
with
36 additions
and
19 deletions
aleksis/apps/alsijil/models.py
+
5
−
3
View file @
02704e20
...
@@ -177,9 +177,11 @@ class Documentation(CalendarEvent):
...
@@ -177,9 +177,11 @@ class Documentation(CalendarEvent):
not
request
.
user
.
has_perm
(
not
request
.
user
.
has_perm
(
"
alsijil.edit_participation_status_for_documentation_rule
"
,
doc
"
alsijil.edit_participation_status_for_documentation_rule
"
,
doc
)
)
and
not
doc
.
participations
.
filter
(
and
not
[
person__pk
=
request
.
user
.
person
.
pk
,
absence_reason__isnull
=
False
d
).
exists
()
for
d
in
doc
.
participations
.
all
()
if
d
.
absence_reason
and
d
.
person_id
==
request
.
user
.
person
.
id
]
)
)
or
(
or
(
absences_exist
absences_exist
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/alsijil/schema/__init__.py
+
31
−
16
View file @
02704e20
from
datetime
import
datetime
from
datetime
import
datetime
from
django.core.exceptions
import
PermissionDenied
from
django.db.models
import
BooleanField
,
ExpressionWrapper
,
Q
from
django.db.models
import
BooleanField
,
ExpressionWrapper
,
Q
import
graphene
import
graphene
...
@@ -76,7 +75,13 @@ class Query(graphene.ObjectType):
...
@@ -76,7 +75,13 @@ class Query(graphene.ObjectType):
def
resolve_documentations_by_course_id
(
root
,
info
,
course_id
,
**
kwargs
):
def
resolve_documentations_by_course_id
(
root
,
info
,
course_id
,
**
kwargs
):
documentations
=
Documentation
.
objects
.
filter
(
documentations
=
Documentation
.
objects
.
filter
(
Q
(
course__pk
=
course_id
)
|
Q
(
amends__course__pk
=
course_id
)
pk__in
=
Documentation
.
objects
.
filter
(
course_id
=
course_id
)
.
values_list
(
"
id
"
,
flat
=
True
)
.
union
(
Documentation
.
objects
.
filter
(
amends__course_id
=
course_id
).
values_list
(
"
id
"
,
flat
=
True
)
)
)
)
return
documentations
return
documentations
...
@@ -112,7 +117,7 @@ class Query(graphene.ObjectType):
...
@@ -112,7 +117,7 @@ class Query(graphene.ObjectType):
)
)
)
)
):
):
r
aise
PermissionDenied
()
r
eturn
[]
# Find all LessonEvents for all Lessons of this Course in this date range
# Find all LessonEvents for all Lessons of this Course in this date range
event_params
=
{
event_params
=
{
...
@@ -150,16 +155,22 @@ class Query(graphene.ObjectType):
...
@@ -150,16 +155,22 @@ class Query(graphene.ObjectType):
if
person
:
if
person
:
person
=
Person
.
objects
.
get
(
pk
=
person
)
person
=
Person
.
objects
.
get
(
pk
=
person
)
if
not
info
.
context
.
user
.
has_perm
(
"
core.view_person_rule
"
,
person
):
if
not
info
.
context
.
user
.
has_perm
(
"
core.view_person_rule
"
,
person
):
r
aise
PermissionDenied
()
r
eturn
[]
elif
has_person
(
info
.
context
.
user
):
elif
has_person
(
info
.
context
.
user
):
person
=
info
.
context
.
user
.
person
person
=
info
.
context
.
user
.
person
else
:
else
:
r
aise
PermissionDenied
()
r
eturn
[]
return
(
return
(
Group
.
objects
.
for_current_school_term_or_all
()
Group
.
objects
.
for_current_school_term_or_all
()
.
filter
(
Q
(
members
=
person
)
|
Q
(
owners
=
person
)
|
Q
(
parent_groups__owners
=
person
))
.
filter
(
.
distinct
()
pk__in
=
Group
.
objects
.
filter
(
members
=
person
)
.
values_list
(
"
id
"
,
flat
=
True
)
.
union
(
Group
.
objects
.
filter
(
owners
=
person
).
values_list
(
"
id
"
,
flat
=
True
))
.
union
(
Group
.
objects
.
filter
(
parent_groups__owners
=
person
).
values_list
(
"
id
"
,
flat
=
True
)
)
)
.
annotate
(
.
annotate
(
is_priority
=
ExpressionWrapper
(
is_priority
=
ExpressionWrapper
(
Q
(
group_type
=
get_site_preferences
()[
"
alsijil__group_type_priority_coursebook
"
]),
Q
(
group_type
=
get_site_preferences
()[
"
alsijil__group_type_priority_coursebook
"
]),
...
@@ -174,20 +185,24 @@ class Query(graphene.ObjectType):
...
@@ -174,20 +185,24 @@ class Query(graphene.ObjectType):
if
person
:
if
person
:
person
=
Person
.
objects
.
get
(
pk
=
person
)
person
=
Person
.
objects
.
get
(
pk
=
person
)
if
not
info
.
context
.
user
.
has_perm
(
"
core.view_person_rule
"
,
person
):
if
not
info
.
context
.
user
.
has_perm
(
"
core.view_person_rule
"
,
person
):
r
aise
PermissionDenied
()
r
eturn
[]
elif
has_person
(
info
.
context
.
user
):
elif
has_person
(
info
.
context
.
user
):
person
=
info
.
context
.
user
.
person
person
=
info
.
context
.
user
.
person
else
:
else
:
r
aise
PermissionDenied
()
r
eturn
[]
return
Course
.
objects
.
filter
(
return
Course
.
objects
.
filter
(
(
pk__in
=
(
Q
(
teachers
=
person
)
Course
.
objects
.
filter
(
teachers
=
person
)
|
Q
(
groups__members
=
person
)
.
values_list
(
"
id
"
,
flat
=
True
)
|
Q
(
groups__owners
=
person
)
.
union
(
Course
.
objects
.
filter
(
groups__members
=
person
).
values_list
(
"
id
"
,
flat
=
True
))
|
Q
(
groups__parent_groups__owners
=
person
)
.
union
(
Course
.
objects
.
filter
(
groups__owners
=
person
).
values_list
(
"
id
"
,
flat
=
True
))
.
union
(
Course
.
objects
.
filter
(
groups__parent_groups__owners
=
person
).
values_list
(
"
id
"
,
flat
=
True
)
)
)
)
&
Q
(
groups__in
=
Group
.
objects
.
for_current_school_term_or_all
())
).
filter
(
groups__in
=
Group
.
objects
.
for_current_school_term_or_all
())
).
distinct
()
@staticmethod
@staticmethod
def
resolve_absence_creation_persons
(
root
,
info
,
**
kwargs
):
def
resolve_absence_creation_persons
(
root
,
info
,
**
kwargs
):
...
...
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