if we're loading a course module with depth = 0, then we don't need to fetch/compute inherited metadata

This commit is contained in:
Chris Dodge
2013-03-20 15:14:14 -04:00
parent f133d3181b
commit f462cd6efa

View File

@@ -376,7 +376,7 @@ class MongoModuleStore(ModuleStoreBase):
return data
def _load_item(self, item, data_cache):
def _load_item(self, item, data_cache, depth=0):
"""
Load an XModuleDescriptor from item, using the children stored in data_cache
"""
@@ -388,7 +388,11 @@ class MongoModuleStore(ModuleStoreBase):
resource_fs = OSFS(root)
metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location']))
metadata_inheritance_tree = None
# if we are loading a course object, if we're not prefetching children (depth != 0) then don't
# bother with the metadata inheritence
if item['location']['category'] != 'course' or depth != 0:
metadata_inheritance_tree = self.get_cached_metadata_inheritance_tree(Location(item['location']))
# TODO (cdodge): When the 'split module store' work has been completed, we should remove
# the 'metadata_inheritance_tree' parameter
@@ -410,7 +414,7 @@ class MongoModuleStore(ModuleStoreBase):
"""
data_cache = self._cache_children(items, depth)
return [self._load_item(item, data_cache) for item in items]
return [self._load_item(item, data_cache, depth) for item in items]
def get_courses(self):
'''