optimize the result-set that gets returned from Mongo on metadata inheritence. We just need the fields which are actually inheritable, so no need to return anything else as it gets filtered out during the computation

This commit is contained in:
Chris Dodge
2013-03-26 23:48:06 -04:00
parent 8abba39590
commit 195fd2d1fe

View File

@@ -267,8 +267,13 @@ class MongoModuleStore(ModuleStoreBase):
'_id.course': location.course,
'_id.category': {'$in': ['course', 'chapter', 'sequential', 'vertical']}
}
# we just want the Location, children, and metadata
record_filter = {'_id': 1, 'definition.children': 1, 'metadata': 1}
# we just want the Location, children, and inheritable metadata
record_filter = {'_id': 1, 'definition.children': 1}
# just get the inheritable metadata since that is all we need for the computation
# this minimizes both data pushed over the wire
for attr in INHERITABLE_METADATA:
record_filter['metadata.{0}'.format(attr)] = 1
# call out to the DB
resultset = self.collection.find(query, record_filter)