This commit is contained in:
JMARyA 2024-09-23 20:07:08 +02:00
parent 9135c2f913
commit 132aeee971
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 8 additions and 2 deletions

View file

@ -143,7 +143,7 @@ pub async fn create_flow_route(
}
#[get("/flow/<id>")]
pub async fn flow_api_route(id: &str, flows: &State<JSONStore<FlowInfo>>) -> FallibleApiResponse {
pub async fn flow_api_route(id: &str) -> FallibleApiResponse {
let flow = Flow::get(id)
.await
.ok_or_else(|| api_error("No such flow"))?;

View file

@ -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::<Location>().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,