stat
This commit is contained in:
parent
58f5b1d93c
commit
f074727130
6 changed files with 101 additions and 22 deletions
|
@ -133,15 +133,21 @@ pub async fn unique_field_route(
|
|||
}
|
||||
|
||||
#[get("/items/expired?<days>")]
|
||||
pub async fn expired_items_route(days: Option<&str>, t: Token, c: &State<Config>) -> FallibleApiResponse {
|
||||
pub async fn expired_items_route(
|
||||
days: Option<&str>,
|
||||
t: Token,
|
||||
c: &State<Config>,
|
||||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let days = if let Some(days) = days {
|
||||
days.parse().map_err(|_| api_error("Invalid days value")).ok()
|
||||
days.parse()
|
||||
.map_err(|_| api_error("Invalid days value"))
|
||||
.ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
|
||||
let t = Transaction::active_expired(days).await;
|
||||
|
||||
Ok(json!(t))
|
||||
|
|
|
@ -83,4 +83,4 @@ pub async fn item_stat_route(
|
|||
"total_transactions": transaction_count,
|
||||
"total_price": total_price
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,10 +130,11 @@ pub async fn inventory_route_variant(
|
|||
}
|
||||
|
||||
/// Returns statistics for the Item Variant
|
||||
#[get("/item/<item_id>/<variant_id>/stat")]
|
||||
#[get("/item/<item_id>/<variant_id>/stat?<full>")]
|
||||
pub async fn variant_stat_route(
|
||||
item_id: &str,
|
||||
variant_id: &str,
|
||||
full: Option<&str>,
|
||||
itemdb: &State<ItemDB>,
|
||||
t: Token,
|
||||
c: &State<Config>,
|
||||
|
@ -146,5 +147,7 @@ pub async fn variant_stat_route(
|
|||
.variant(variant_id)
|
||||
.ok_or_else(variant_does_not_exist_error)?;
|
||||
|
||||
Ok(variant.stat().await)
|
||||
Ok(variant
|
||||
.stat(full.map(|x| x == "1" || x == "true").unwrap_or(false))
|
||||
.await)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue