add latest price route
This commit is contained in:
parent
0d4ed15460
commit
9c03d38f6e
3 changed files with 31 additions and 4 deletions
|
@ -28,5 +28,29 @@ pub async fn variant_price_history_by_origin(
|
|||
.variant(variant_id)
|
||||
.ok_or_else(variant_does_not_exist_error)?;
|
||||
|
||||
Ok(json!(variant.price_history_by_origin(origin).await))
|
||||
Ok(json!(variant.price_history_by_origin(origin, None).await))
|
||||
}
|
||||
|
||||
#[get("/item/<item_id>/<variant_id>/price_latest?<origin>")]
|
||||
pub async fn variant_price_latest_by_origin(
|
||||
item_id: &str,
|
||||
variant_id: &str,
|
||||
itemdb: &State<ItemDB>,
|
||||
t: Token,
|
||||
c: &State<Config>,
|
||||
origin: &str,
|
||||
) -> FallibleApiResponse {
|
||||
check_auth!(t, c);
|
||||
|
||||
let variant = itemdb
|
||||
.get_item(item_id)
|
||||
.ok_or_else(item_does_not_exist_error)?
|
||||
.variant(variant_id)
|
||||
.ok_or_else(variant_does_not_exist_error)?;
|
||||
|
||||
Ok(json!(variant
|
||||
.price_history_by_origin(origin, Some(1))
|
||||
.await
|
||||
.first()
|
||||
.unwrap()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue