Commit 4131f867 by Christina Roberts

Merge pull request #1694 from MITx/fix/cdodge/disable-metadata-inheritence-computation-on-import

add an array of courses to not refresh the metadata cache on writes. Thi...
parents e4437b7a 5dbb153a
...@@ -246,6 +246,7 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -246,6 +246,7 @@ class MongoModuleStore(ModuleStoreBase):
self.fs_root = path(fs_root) self.fs_root = path(fs_root)
self.error_tracker = error_tracker self.error_tracker = error_tracker
self.render_template = render_template self.render_template = render_template
self.ignore_write_events_on_courses = []
def get_metadata_inheritance_tree(self, location): def get_metadata_inheritance_tree(self, location):
''' '''
...@@ -330,6 +331,11 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -330,6 +331,11 @@ class MongoModuleStore(ModuleStoreBase):
return tree return tree
def refresh_cached_metadata_inheritance_tree(self, location):
pseudo_course_id = '/'.join([location.org, location.course])
if pseudo_course_id not in self.ignore_write_events_on_courses:
self.get_cached_metadata_inheritance_tree(location, force_refresh = True)
def clear_cached_metadata_inheritance_tree(self, location): def clear_cached_metadata_inheritance_tree(self, location):
key_name = '{0}/{1}'.format(location.org, location.course) key_name = '{0}/{1}'.format(location.org, location.course)
if self.metadata_inheritance_cache is not None: if self.metadata_inheritance_cache is not None:
...@@ -520,7 +526,7 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -520,7 +526,7 @@ class MongoModuleStore(ModuleStoreBase):
raise DuplicateItemError(location) raise DuplicateItemError(location)
# recompute (and update) the metadata inheritance tree which is cached # recompute (and update) the metadata inheritance tree which is cached
self.get_cached_metadata_inheritance_tree(Location(location), force_refresh = True) self.refresh_cached_metadata_inheritance_tree(Location(location))
def get_course_for_item(self, location, depth=0): def get_course_for_item(self, location, depth=0):
''' '''
...@@ -590,7 +596,7 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -590,7 +596,7 @@ class MongoModuleStore(ModuleStoreBase):
self._update_single_item(location, {'definition.children': children}) self._update_single_item(location, {'definition.children': children})
# recompute (and update) the metadata inheritance tree which is cached # recompute (and update) the metadata inheritance tree which is cached
self.get_cached_metadata_inheritance_tree(Location(location), force_refresh = True) self.refresh_cached_metadata_inheritance_tree(Location(location))
def update_metadata(self, location, metadata): def update_metadata(self, location, metadata):
""" """
...@@ -616,7 +622,7 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -616,7 +622,7 @@ class MongoModuleStore(ModuleStoreBase):
self._update_single_item(location, {'metadata': metadata}) self._update_single_item(location, {'metadata': metadata})
# recompute (and update) the metadata inheritance tree which is cached # recompute (and update) the metadata inheritance tree which is cached
self.get_cached_metadata_inheritance_tree(loc, force_refresh = True) self.refresh_cached_metadata_inheritance_tree(loc)
def delete_item(self, location): def delete_item(self, location):
""" """
...@@ -639,8 +645,7 @@ class MongoModuleStore(ModuleStoreBase): ...@@ -639,8 +645,7 @@ class MongoModuleStore(ModuleStoreBase):
# from overriding our default value set in the init method. # from overriding our default value set in the init method.
safe=self.collection.safe) safe=self.collection.safe)
# recompute (and update) the metadata inheritance tree which is cached # recompute (and update) the metadata inheritance tree which is cached
self.get_cached_metadata_inheritance_tree(Location(location), force_refresh = True) self.refresh_cached_metadata_inheritance_tree(Location(location))
def get_parent_locations(self, location, course_id): def get_parent_locations(self, location, course_id):
'''Find all locations that are the parents of this location in this '''Find all locations that are the parents of this location in this
......
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