def vehical_visits(): logger.debug("post request ") data = request.json store.add(data) rabbit_mqueue.connect() rabbit_mqueue.publish_message(json.dumps(data)) return json.dumps({"id": data["id"]})
def vehical_update_shortest_path(vehical_id): shortest_path = request.json['shortest_path'] output = store.update(vehical_id, 'shortest_path', shortest_path) logger.debug(output) return json.dumps(output)
def vehical_path(vehical_id): logger.debug(f"vehical path requested {vehical_id}") return json.dumps(store.get(vehical_id))
def get(self, vehical_id): logger.debug(f"vehical_data = {self.vehical_data}") for vdata in self.vehical_data: if vdata["id"] == int(vehical_id): return vdata return {}
def publish_message(self, message): logger.debug(message) self.channel.basic_publish(exchange=self.exchange, routing_key=self.queue, body=message)
def vehical_update_shortest_path(vehical_id): shortest_path = request.json['shortest_path'] logger.info(f"shortest path is = {shortest_path} for vehical = {vehical_id}") output = store.update(vehical_id, 'shortest_path', shortest_path) logger.debug(f"output = {output}") return json.dumps(output)