Commit 0770b7f1 by David Ormsbee

Make searching for reused keys more efficient.

parent 3d167093
...@@ -324,11 +324,15 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase): ...@@ -324,11 +324,15 @@ class MixedModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase):
This key may represent a course that doesn't exist in this modulestore. This key may represent a course that doesn't exist in this modulestore.
""" """
possible_keys = [
store.make_course_key(org, course, run)
for store in self.modulestores
]
# If there is a mapping that match this org/course/run, use that # If there is a mapping that match this org/course/run, use that
for course_id, store in self.mappings.iteritems(): for key in possible_keys:
candidate_key = store.make_course_key(org, course, run) if key in self.mappings:
if candidate_key == course_id: return self.mappings[key]
return candidate_key
# Otherwise, return the key created by the default store # Otherwise, return the key created by the default store
return self.default_modulestore.make_course_key(org, course, run) return self.default_modulestore.make_course_key(org, course, run)
......
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