Wrap get_item inside bulk_operations internally, to cache query for active versions
[LMS-11402]
This commit is contained in:
@@ -849,13 +849,14 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
|
||||
# The supplied UsageKey is of the wrong type, so it can't possibly be stored in this modulestore.
|
||||
raise ItemNotFoundError(usage_key)
|
||||
|
||||
course = self._lookup_course(usage_key.course_key)
|
||||
items = self._load_items(course, [BlockKey.from_usage_key(usage_key)], depth, lazy=True, **kwargs)
|
||||
if len(items) == 0:
|
||||
raise ItemNotFoundError(usage_key)
|
||||
elif len(items) > 1:
|
||||
log.debug("Found more than one item for '{}'".format(usage_key))
|
||||
return items[0]
|
||||
with self.bulk_operations(usage_key.course_key):
|
||||
course = self._lookup_course(usage_key.course_key)
|
||||
items = self._load_items(course, [BlockKey.from_usage_key(usage_key)], depth, lazy=True, **kwargs)
|
||||
if len(items) == 0:
|
||||
raise ItemNotFoundError(usage_key)
|
||||
elif len(items) > 1:
|
||||
log.debug("Found more than one item for '{}'".format(usage_key))
|
||||
return items[0]
|
||||
|
||||
def get_items(self, course_locator, settings=None, content=None, qualifiers=None, **kwargs):
|
||||
"""
|
||||
|
||||
@@ -321,9 +321,9 @@ class TestMixedModuleStore(CourseComparisonTest):
|
||||
# problem: find draft item, find all items pertinent to inheritance computation
|
||||
# non-existent problem: find draft, find published
|
||||
# split:
|
||||
# problem: active_versions, structure, then active_versions again?
|
||||
# problem: active_versions, structure
|
||||
# non-existent problem: ditto
|
||||
@ddt.data(('draft', [2, 2], 0), ('split', [3, 3], 0))
|
||||
@ddt.data(('draft', [2, 2], 0), ('split', [2, 2], 0))
|
||||
@ddt.unpack
|
||||
def test_get_item(self, default_ms, max_find, max_send):
|
||||
self.initdb(default_ms)
|
||||
@@ -817,8 +817,8 @@ class TestMixedModuleStore(CourseComparisonTest):
|
||||
xml_store.create_course("org", "course", "run", self.user_id)
|
||||
|
||||
# draft is 2: find out which ms owns course, get item
|
||||
# split: find out which ms owns course, active_versions, structure, definition (definition s/b unnecessary unless lazy is false)
|
||||
@ddt.data(('draft', 2, 0), ('split', 4, 0))
|
||||
# split: active_versions, structure, definition (to load course wiki string)
|
||||
@ddt.data(('draft', 2, 0), ('split', 3, 0))
|
||||
@ddt.unpack
|
||||
def test_get_course(self, default_ms, max_find, max_send):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user