diff --git a/src/routes/flow.rs b/src/routes/flow.rs index 7ac2600..c52cb08 100644 --- a/src/routes/flow.rs +++ b/src/routes/flow.rs @@ -143,7 +143,7 @@ pub async fn create_flow_route( } #[get("/flow/")] -pub async fn flow_api_route(id: &str, flows: &State>) -> FallibleApiResponse { +pub async fn flow_api_route(id: &str) -> FallibleApiResponse { let flow = Flow::get(id) .await .ok_or_else(|| api_error("No such flow"))?; diff --git a/src/transaction.rs b/src/transaction.rs index f7b8f0b..a954398 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -179,13 +179,19 @@ impl Transaction { impl mongod::ToAPI for Transaction { async fn api(&self) -> serde_json::Value { + let location = if let Some(loc) = &self.location { + Some(loc.get::().await.api().await) + } else { + None + }; + json!({ "uuid": self._id, "item": self.item, "variant": self.variant, "price": self.price, "origin": self.origin, - "location": self.location.as_ref().map(|x| x.id().to_string()), + "location": location, "timestamp": self.timestamp, "consumed": self.consumed, "note": self.note,