def get_event(self, id): query = {"_id":ObjectId(id),"value.x":{"$exists":True},"value.y":{"$exists":True},"value.z":{"$exists":True}} event = self.collection.find_one(query) if event: event = get_axis_data(event) else: query = {"_id": ObjectId(id), "x": {"$exists": True}, "y": {"$exists": True}, "z": {"$exists": True}} event = self.collection.find_one(query) event = get_axis_data(event) return event
def get_events(self, truck_id, package_id, is_above_threshold=True): self.logger.info("Started loading events from mongodb cursor") events = [] query = {"truck_id": truck_id, "package_id": package_id, "is_above_threshold": is_above_threshold,"x": {"$exists": True},"y": {"$exists":True}, "z": {"$exists": True}} cursor = self.get_cursor(query) for line in cursor: events.append(get_axis_data(line)) if cursor: query = {"truck_id":truck_id,"package_id":package_id,"is_above_threshold": is_above_threshold,"value.x":{"$exists":True},"value.y":{"$exists":True},"value.z":{"$exists":True}} cursor = self.get_cursor(query) for line in cursor: events.append(get_axis_data(line)) self.logger.info("Done loading events from mongodb cursor") return events