Commit a81e9a67 by Chris Dodge

additional courseware view optimizations. Do a 'depth' fetch on the selected…

additional courseware view optimizations. Do a 'depth' fetch on the selected section so that it does a more efficient set of queries to the database. Also, in the CachingDescriptorSystem, if we have a 'cache miss', when we do the actual fetch (which creates a new 'system'), keep that fetched data around in our own collection, in case it is queried again
parent b482e2ac
......@@ -64,7 +64,10 @@ class CachingDescriptorSystem(MakoDescriptorSystem):
location = Location(location)
json_data = self.module_data.get(location)
if json_data is None:
return self.modulestore.get_item(location)
module = self.modulestore.get_item(location)
if module is not None:
self.module_data.update(module.system.module_data)
return module
else:
# load the module and apply the inherited metadata
try:
......
......@@ -306,6 +306,10 @@ def index(request, course_id, chapter=None, section=None,
# Specifically asked-for section doesn't exist
raise Http404
# cdodge: this looks silly, but let's refetch the section_descriptor with depth=None
# which will prefetch the children more efficiently than doing a recursive load
section_descriptor = modulestore().get_instance(course.id, section_descriptor.location, depth=None)
# Load all descendants of the section, because we're going to display its
# html, which in general will need all of its children
section_module_cache = StudentModuleCache.cache_for_descriptor_descendents(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment