def retrievePropertiesWithRating(self, desiredRating): return [Property.unmarshal(p) for p in self.properties.select('select * from ' + self.properties.name) if Property._key_from(p) in ratingsCache and ratingsCache[Property._key_from(p)] == desiredRating]
def initRatingsCacheIfEmpty(propertiesDomain, ratingsDomain): global ratingsCache if not ratingsCache: sys.stdout.write('Loading ratings cache, you should see this message in the logs only once per run... ') sys.stdout.flush() ratingsCache = dict([(propKey, ratingsDomain.get_item(propKey)['rating']) for propKey in [Property._key_from(prop) for prop in propertiesDomain.select('select * from ' + propertiesDomain.name)] if ratingsDomain.get_item(propKey)]) sys.stdout.write('done\n') sys.stdout.flush()
def retrieveNewProperties(self): return [Property.unmarshal(p) for p in self.properties.select('select * from ' + self.properties.name) if Property._key_from(p) not in ratingsCache]