Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1b3efaba
Commit
1b3efaba
authored
Jun 10, 2015
by
Waheed Ahmed
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8457 from edx/waheed/tnl2425-fix-slow-transaction-xblock-outline
Fixed slow transaction on xblock outline handler.
parents
2092d732
b328c0dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
cms/djangoapps/contentstore/views/item.py
+8
-7
cms/djangoapps/contentstore/views/tests/test_item.py
+22
-0
No files found.
cms/djangoapps/contentstore/views/item.py
View file @
1b3efaba
...
...
@@ -332,13 +332,14 @@ def xblock_outline_handler(request, usage_key_string):
response_format
=
request
.
REQUEST
.
get
(
'format'
,
'html'
)
if
response_format
==
'json'
or
'application/json'
in
request
.
META
.
get
(
'HTTP_ACCEPT'
,
'application/json'
):
store
=
modulestore
()
root_xblock
=
store
.
get_item
(
usage_key
)
return
JsonResponse
(
create_xblock_info
(
root_xblock
,
include_child_info
=
True
,
course_outline
=
True
,
include_children_predicate
=
lambda
xblock
:
not
xblock
.
category
==
'vertical'
))
with
store
.
bulk_operations
(
usage_key
.
course_key
):
root_xblock
=
store
.
get_item
(
usage_key
)
return
JsonResponse
(
create_xblock_info
(
root_xblock
,
include_child_info
=
True
,
course_outline
=
True
,
include_children_predicate
=
lambda
xblock
:
not
xblock
.
category
==
'vertical'
))
else
:
return
Http404
...
...
cms/djangoapps/contentstore/views/tests/test_item.py
View file @
1b3efaba
...
...
@@ -1410,6 +1410,28 @@ class TestXBlockInfo(ItemTest):
json_response
=
json
.
loads
(
resp
.
content
)
self
.
validate_course_xblock_info
(
json_response
,
course_outline
=
True
)
def
test_xblock_outline_handler_mongo_calls
(
self
):
expected_calls
=
5
with
self
.
store
.
default_store
(
ModuleStoreEnum
.
Type
.
split
):
course
=
CourseFactory
.
create
()
chapter
=
ItemFactory
.
create
(
parent_location
=
course
.
location
,
category
=
'chapter'
,
display_name
=
'Week 1'
)
outline_url
=
reverse_usage_url
(
'xblock_outline_handler'
,
chapter
.
location
)
with
check_mongo_calls
(
expected_calls
):
self
.
client
.
get
(
outline_url
,
HTTP_ACCEPT
=
'application/json'
)
sequential
=
ItemFactory
.
create
(
parent_location
=
chapter
.
location
,
category
=
'sequential'
,
display_name
=
'Sequential 1'
)
ItemFactory
.
create
(
parent_location
=
sequential
.
location
,
category
=
'vertical'
,
display_name
=
'Vertical 1'
)
# calls should be same after adding two new children.
with
check_mongo_calls
(
expected_calls
):
self
.
client
.
get
(
outline_url
,
HTTP_ACCEPT
=
'application/json'
)
def
test_entrance_exam_chapter_xblock_info
(
self
):
chapter
=
ItemFactory
.
create
(
parent_location
=
self
.
course
.
location
,
category
=
'chapter'
,
display_name
=
"Entrance Exam"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment