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
e624ff3b
Commit
e624ff3b
authored
Aug 22, 2014
by
Don Mitchell
Committed by
Calen Pennington
Aug 27, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make path_to_location use bulk_write_operation for performance.
parent
7d8088d2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
6 deletions
+13
-6
common/lib/xmodule/xmodule/modulestore/mixed.py
+3
-0
common/lib/xmodule/xmodule/modulestore/search.py
+2
-0
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+1
-2
lms/djangoapps/courseware/model_data.py
+2
-0
lms/djangoapps/courseware/tests/test_module_render.py
+5
-4
No files found.
common/lib/xmodule/xmodule/modulestore/mixed.py
View file @
e624ff3b
...
@@ -651,5 +651,8 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
...
@@ -651,5 +651,8 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
If course_id is None, the default store is used.
If course_id is None, the default store is used.
"""
"""
store
=
self
.
_get_modulestore_for_courseid
(
course_id
)
store
=
self
.
_get_modulestore_for_courseid
(
course_id
)
if
hasattr
(
store
,
'bulk_write_operations'
):
with
store
.
bulk_write_operations
(
course_id
):
with
store
.
bulk_write_operations
(
course_id
):
yield
yield
else
:
yield
common/lib/xmodule/xmodule/modulestore/search.py
View file @
e624ff3b
...
@@ -68,6 +68,8 @@ def path_to_location(modulestore, usage_key):
...
@@ -68,6 +68,8 @@ def path_to_location(modulestore, usage_key):
newpath
=
(
next_usage
,
path
)
newpath
=
(
next_usage
,
path
)
queue
.
append
((
parent
,
newpath
))
queue
.
append
((
parent
,
newpath
))
# doesn't write but does multiple reads. bulk_write minimizes reads too
with
modulestore
.
bulk_write_operations
(
usage_key
.
course_key
):
if
not
modulestore
.
has_item
(
usage_key
):
if
not
modulestore
.
has_item
(
usage_key
):
raise
ItemNotFoundError
(
usage_key
)
raise
ItemNotFoundError
(
usage_key
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
e624ff3b
...
@@ -717,7 +717,7 @@ class TestMixedModuleStore(unittest.TestCase):
...
@@ -717,7 +717,7 @@ class TestMixedModuleStore(unittest.TestCase):
# TODO: LMS-11220: Document why draft send count is 5
# TODO: LMS-11220: Document why draft send count is 5
# TODO: LMS-11220: Document why draft find count is 18
# TODO: LMS-11220: Document why draft find count is 18
# TODO: LMS-11220: Document why split find count is 16
# TODO: LMS-11220: Document why split find count is 16
@ddt.data
((
'draft'
,
[
1
8
,
5
],
0
),
(
'split'
,
[
16
,
6
],
0
))
@ddt.data
((
'draft'
,
[
1
9
,
5
],
0
),
(
'split'
,
[
2
,
2
],
0
))
@ddt.unpack
@ddt.unpack
def
test_path_to_location
(
self
,
default_ms
,
num_finds
,
num_sends
):
def
test_path_to_location
(
self
,
default_ms
,
num_finds
,
num_sends
):
"""
"""
...
@@ -736,7 +736,6 @@ class TestMixedModuleStore(unittest.TestCase):
...
@@ -736,7 +736,6 @@ class TestMixedModuleStore(unittest.TestCase):
(
course_key
,
"Chapter_x"
,
None
,
None
)),
(
course_key
,
"Chapter_x"
,
None
,
None
)),
)
)
mongo_store
=
self
.
store
.
_get_modulestore_for_courseid
(
self
.
_course_key_from_string
(
self
.
MONGO_COURSEID
))
for
location
,
expected
in
should_work
:
for
location
,
expected
in
should_work
:
with
check_mongo_calls
(
num_finds
.
pop
(
0
),
num_sends
):
with
check_mongo_calls
(
num_finds
.
pop
(
0
),
num_sends
):
self
.
assertEqual
(
path_to_location
(
self
.
store
,
location
),
expected
)
self
.
assertEqual
(
path_to_location
(
self
.
store
,
location
),
expected
)
...
...
lms/djangoapps/courseware/model_data.py
View file @
e624ff3b
...
@@ -21,6 +21,7 @@ from django.contrib.auth.models import User
...
@@ -21,6 +21,7 @@ from django.contrib.auth.models import User
from
xblock.runtime
import
KeyValueStore
from
xblock.runtime
import
KeyValueStore
from
xblock.exceptions
import
KeyValueMultiSaveError
,
InvalidScopeError
from
xblock.exceptions
import
KeyValueMultiSaveError
,
InvalidScopeError
from
xblock.fields
import
Scope
,
UserScope
from
xblock.fields
import
Scope
,
UserScope
from
xmodule.modulestore.django
import
modulestore
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
...
@@ -109,6 +110,7 @@ class FieldDataCache(object):
...
@@ -109,6 +110,7 @@ class FieldDataCache(object):
return
descriptors
return
descriptors
with
modulestore
()
.
bulk_write_operations
(
descriptor
.
location
.
course_key
):
descriptors
=
get_child_descriptors
(
descriptor
,
depth
,
descriptor_filter
)
descriptors
=
get_child_descriptors
(
descriptor
,
depth
,
descriptor_filter
)
return
FieldDataCache
(
descriptors
,
course_id
,
user
,
select_for_update
)
return
FieldDataCache
(
descriptors
,
course_id
,
user
,
select_for_update
)
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
e624ff3b
...
@@ -326,14 +326,15 @@ class TestTOC(ModuleStoreTestCase):
...
@@ -326,14 +326,15 @@ class TestTOC(ModuleStoreTestCase):
self
.
request
=
factory
.
get
(
chapter_url
)
self
.
request
=
factory
.
get
(
chapter_url
)
self
.
request
.
user
=
UserFactory
()
self
.
request
.
user
=
UserFactory
()
self
.
modulestore
=
self
.
store
.
_get_modulestore_for_courseid
(
self
.
course_key
)
self
.
modulestore
=
self
.
store
.
_get_modulestore_for_courseid
(
self
.
course_key
)
with
check_mongo_calls
(
num_finds
,
num_sends
):
self
.
toy_course
=
self
.
store
.
get_course
(
self
.
toy_loc
,
depth
=
2
)
self
.
toy_course
=
self
.
store
.
get_course
(
self
.
toy_loc
,
depth
=
2
)
with
check_mongo_calls
(
num_finds
,
num_sends
):
self
.
field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
self
.
field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
self
.
toy_loc
,
self
.
request
.
user
,
self
.
toy_course
,
depth
=
2
)
self
.
toy_loc
,
self
.
request
.
user
,
self
.
toy_course
,
depth
=
2
)
# TODO: LMS-11220: Document why split find count is 21
# TODO: LMS-11220: Document why split find count is 21
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
3
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
21
,
0
))
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
1
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
5
,
0
))
@ddt.unpack
@ddt.unpack
def
test_toc_toy_from_chapter
(
self
,
default_ms
,
num_finds
,
num_sends
):
def
test_toc_toy_from_chapter
(
self
,
default_ms
,
num_finds
,
num_sends
):
with
self
.
store
.
default_store
(
default_ms
):
with
self
.
store
.
default_store
(
default_ms
):
...
@@ -361,7 +362,7 @@ class TestTOC(ModuleStoreTestCase):
...
@@ -361,7 +362,7 @@ class TestTOC(ModuleStoreTestCase):
self
.
assertIn
(
toc_section
,
actual
)
self
.
assertIn
(
toc_section
,
actual
)
# TODO: LMS-11220: Document why split find count is 21
# TODO: LMS-11220: Document why split find count is 21
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
3
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
21
,
0
))
@ddt.data
((
ModuleStoreEnum
.
Type
.
mongo
,
1
,
0
),
(
ModuleStoreEnum
.
Type
.
split
,
5
,
0
))
@ddt.unpack
@ddt.unpack
def
test_toc_toy_from_section
(
self
,
default_ms
,
num_finds
,
num_sends
):
def
test_toc_toy_from_section
(
self
,
default_ms
,
num_finds
,
num_sends
):
with
self
.
store
.
default_store
(
default_ms
):
with
self
.
store
.
default_store
(
default_ms
):
...
...
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