update
This commit is contained in:
parent
a8dfe5f0e9
commit
37475460e2
5 changed files with 93 additions and 2 deletions
|
@ -16,6 +16,7 @@ use serde_json::json;
|
|||
|
||||
use crate::check_auth;
|
||||
use crate::config::Config;
|
||||
use crate::db::get_items_without_min_satisfied;
|
||||
use crate::db::ItemDB;
|
||||
use crate::routes::Token;
|
||||
use crate::transaction::Transaction;
|
||||
|
@ -108,3 +109,35 @@ pub async fn unique_field_route(
|
|||
_ => Err(api_error("Unknown field")),
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/items/expired")]
|
||||
pub async fn expired_items_route(t: Token, c: &State<Config>) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let t = Transaction::active_expired().await;
|
||||
|
||||
Ok(json!(t))
|
||||
}
|
||||
|
||||
#[get("/items/min")]
|
||||
pub async fn min_items_route(
|
||||
itemdb: &State<ItemDB>,
|
||||
t: Token,
|
||||
c: &State<Config>,
|
||||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let t: Vec<_> = get_items_without_min_satisfied(&itemdb)
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|x| {
|
||||
json!({
|
||||
"item_variant": x.0,
|
||||
"need": x.1
|
||||
}
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(json!(t))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue