def emit_entity(self, collection, data): data['collections'] = [collection] entity = Entity.save(data, merge=True) db.session.flush() update_entity_full.delay(entity.id) log.info("Entity [%s]: %s", entity.id, entity.name) self.entity_cache[collection.id].append(entity) return entity
def emit_collection(self, collection): db.session.commit() entities = self.entity_cache.pop(collection.id, []) deleted_ids = [] for entity in collection.entities: if entity not in entities: entity.delete() deleted_ids.append(entity.id) db.session.commit() for entity_id in deleted_ids: update_entity_full.delay(entity_id)
def updateentities(): """Re-index all the entities.""" q = db.session.query(Entity.id) for (entity_id, ) in q: update_entity_full.delay(entity_id)