Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
4a1caf6c
Commit
4a1caf6c
authored
6 years ago
by
Alex Dusenbery
Committed by
Alex Dusenbery
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
EDUCATOR-3374 | Hacky query to fix inline discussions performance.
parent
39a4a396
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/djangoapps/django_comment_common/models.py
+15
-3
15 additions, 3 deletions
common/djangoapps/django_comment_common/models.py
lms/djangoapps/courseware/tests/test_discussion_xblock.py
+5
-3
5 additions, 3 deletions
lms/djangoapps/courseware/tests/test_discussion_xblock.py
with
20 additions
and
6 deletions
common/djangoapps/django_comment_common/models.py
+
15
−
3
View file @
4a1caf6c
...
...
@@ -145,13 +145,25 @@ def all_permissions_for_user_in_course(user, course_id): # pylint: disable=inva
if
course
is
None
:
raise
ItemNotFoundError
(
course_id
)
all_roles
=
{
role
.
name
for
role
in
Role
.
objects
.
filter
(
users
=
user
,
course_id
=
course_id
)}
all_roles
=
{
role
for
role
in
Role
.
objects
.
filter
(
users
=
user
,
course_id
=
course_id
)}
role_names
=
{
role
.
name
for
role
in
all_roles
}
# TODO: EDUCATOR-3374
# The `roles__users__roles__in=all_roles` part of this filter is a hack to get the new
# Aurora MySql query planner to properly use the unique index on the roles/users join table.
# Without this hack, the planner uses a unique index on (role_id, user_id) to do lookup
# by user_id only, which is a completely inefficient way to use that index.
permission_queryset
=
Permission
.
objects
.
filter
(
roles__users
=
user
,
roles__course_id
=
course_id
,
roles__users__roles__in
=
all_roles
).
distinct
()
permissions
=
{
permission
.
name
for
permission
in
P
ermission
.
objects
.
filter
(
roles__users
=
user
,
roles__course_id
=
course_id
)
if
not
permission_blacked_out
(
course
,
all_rol
es
,
permission
.
name
)
in
p
ermission
_queryset
if
not
permission_blacked_out
(
course
,
role_nam
es
,
permission
.
name
)
}
return
permissions
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/courseware/tests/test_discussion_xblock.py
+
5
−
3
View file @
4a1caf6c
...
...
@@ -402,11 +402,13 @@ class TestXBlockQueryLoad(SharedModuleStoreTestCase):
discussion_target
=
'
Target Discussion
'
,
))
#
3
queries are required to do first discussion xblock render:
#
2
queries are required to do first discussion xblock render:
# * django_comment_client_role
# * django_comment_client_permission
# * lms_xblock_xblockasidesconfig
num_queries
=
3
# If the query for roles returned a non-empty result set, there would be
# an additional query against django_comment_client_permission, but there
# are no roles associated with this test.
num_queries
=
2
for
discussion
in
discussions
:
discussion_xblock
=
get_module_for_descriptor_internal
(
user
=
user
,
...
...
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