group
This commit is contained in:
parent
fb6a96ff55
commit
94459d5481
7 changed files with 90 additions and 14 deletions
|
@ -82,20 +82,25 @@ pub async fn supply_log_route(
|
|||
}
|
||||
|
||||
/// Returns current active Transactions for Item
|
||||
#[get("/item/<item_id>/inventory")]
|
||||
#[get("/item/<item_id>/inventory?<origin>")]
|
||||
pub async fn inventory_route(
|
||||
item_id: &str,
|
||||
itemdb: &State<ItemDB>,
|
||||
t: Token,
|
||||
c: &State<Config>,
|
||||
origin: Option<&str>,
|
||||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let variant = itemdb
|
||||
let item = itemdb
|
||||
.get_item(item_id)
|
||||
.ok_or_else(item_does_not_exist_error)?;
|
||||
|
||||
let transactions = variant.inventory().await;
|
||||
let transactions = if let Some(origin) = origin {
|
||||
item.inventory_by_origin(origin).await
|
||||
} else {
|
||||
item.inventory().await
|
||||
};
|
||||
|
||||
Ok(json!(mongod::vec_to_api(&transactions).await))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue