mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-22 00:43:39 +00:00
Check for deleted items
This commit is contained in:
parent
142a7fbb52
commit
d993eb695a
2 changed files with 18 additions and 0 deletions
|
@ -58,6 +58,17 @@ pub fn format_new_item(item: &ShopItem) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn format_deleted_item(item: &ShopItem) -> String {
|
||||
formatdoc! {
|
||||
"*Item DELETED:* {full_name}
|
||||
*Description:* {description}
|
||||
*Price:* {price}",
|
||||
full_name = item.full_name,
|
||||
description = item.description.as_ref().unwrap_or(&"_not set_".into()),
|
||||
price = item.price,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod format_new_tests {
|
||||
use super::*;
|
||||
|
|
|
@ -58,6 +58,13 @@ async fn run_scrape(env: Env) -> Result<String> {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if any items have been removed.
|
||||
for item in &old_items {
|
||||
if !available_items.iter().any(|i| i.id == item.id) {
|
||||
result.push(format::format_deleted_item(item));
|
||||
}
|
||||
}
|
||||
|
||||
// If there are any updates/new items, send a message to the Slack webhook.
|
||||
if result.is_empty() {
|
||||
return Ok("No changes detected".into());
|
||||
|
|
Loading…
Reference in a new issue