mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-12 20:52:24 +00:00
Add stock info to scraper
This commit is contained in:
parent
4995a1e172
commit
4aad2a3228
2 changed files with 8 additions and 1 deletions
|
@ -15,6 +15,9 @@ pub struct ShopItem {
|
||||||
|
|
||||||
#[serde(rename = "Cost Hours")]
|
#[serde(rename = "Cost Hours")]
|
||||||
pub price: i32,
|
pub price: i32,
|
||||||
|
|
||||||
|
#[serde(rename = "Stock")]
|
||||||
|
pub stock: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ShopItems = Vec<ShopItem>;
|
pub type ShopItems = Vec<ShopItem>;
|
||||||
|
|
|
@ -25,10 +25,14 @@ async fn run_scrape(env: Env) -> Result<String> {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
for item in available_items {
|
for item in available_items {
|
||||||
result.push(format!(
|
result.push(format!(
|
||||||
"`{full_name}` - {price} {}",
|
"`{full_name}` - {price} {} - Stock: {stock}",
|
||||||
if item.price == 1 { "ticket" } else { "tickets" },
|
if item.price == 1 { "ticket" } else { "tickets" },
|
||||||
full_name = item.full_name.trim(),
|
full_name = item.full_name.trim(),
|
||||||
price = item.price,
|
price = item.price,
|
||||||
|
stock = item
|
||||||
|
.stock
|
||||||
|
.map(|stock| stock.to_string())
|
||||||
|
.unwrap_or("Unlimited".into())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue