mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-25 02:13:41 +00:00
Add emoji formatting to stock updates
This commit is contained in:
parent
4b0e3605f4
commit
ded273b12c
1 changed files with 29 additions and 7 deletions
|
@ -18,7 +18,16 @@ pub fn format_item_diff(old: &ShopItem, new: &ShopItem) -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if old.price != new.price {
|
if old.price != new.price {
|
||||||
result.push(format!("*Price:* {} → {}", old.price, new.price));
|
result.push(format!(
|
||||||
|
"*Price:* {} → {} {}",
|
||||||
|
old.price,
|
||||||
|
new.price,
|
||||||
|
if old.price > new.price {
|
||||||
|
"🔽"
|
||||||
|
} else {
|
||||||
|
"🔼"
|
||||||
|
}
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if old.description != new.description {
|
if old.description != new.description {
|
||||||
|
@ -43,13 +52,22 @@ pub fn format_item_diff(old: &ShopItem, new: &ShopItem) -> Option<String> {
|
||||||
|
|
||||||
if old.stock != new.stock {
|
if old.stock != new.stock {
|
||||||
result.push(format!(
|
result.push(format!(
|
||||||
"*Stock:* {} → {}",
|
"*Stock:* {} → {}{}",
|
||||||
old.stock
|
old.stock
|
||||||
.map(|stock| stock.to_string())
|
.map(|stock| stock.to_string())
|
||||||
.unwrap_or("Unlimited".into()),
|
.unwrap_or("Unlimited".into()),
|
||||||
new.stock
|
new.stock
|
||||||
.map(|stock| stock.to_string())
|
.map(|stock| stock.to_string())
|
||||||
.unwrap_or("Unlimited".into())
|
.unwrap_or("Unlimited".into()),
|
||||||
|
if let (Some(old_stock), Some(new_stock)) = (old.stock, new.stock) {
|
||||||
|
if old_stock > new_stock {
|
||||||
|
" 🔽"
|
||||||
|
} else {
|
||||||
|
" 🔼"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +76,9 @@ pub fn format_item_diff(old: &ShopItem, new: &ShopItem) -> Option<String> {
|
||||||
|
|
||||||
pub fn format_new_item(item: &ShopItem) -> String {
|
pub fn format_new_item(item: &ShopItem) -> String {
|
||||||
formatdoc! {
|
formatdoc! {
|
||||||
"*New item added:* {full_name}
|
"*New item added*
|
||||||
|
|
||||||
|
*Name:* {full_name}
|
||||||
*Description:* {description}
|
*Description:* {description}
|
||||||
*Fulfillment info:* {fullfilment_info}
|
*Fulfillment info:* {fullfilment_info}
|
||||||
*Price:* {price}
|
*Price:* {price}
|
||||||
|
@ -191,7 +211,9 @@ mod format_new_tests {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format_new_item(&item),
|
format_new_item(&item),
|
||||||
indoc! {"
|
indoc! {"
|
||||||
*New item added:* Test
|
*New item added*
|
||||||
|
|
||||||
|
*Name:* Test
|
||||||
*Description:* Lorem ipsum
|
*Description:* Lorem ipsum
|
||||||
*Fulfillment info:* Dolor sit amet
|
*Fulfillment info:* Dolor sit amet
|
||||||
*Price:* 1
|
*Price:* 1
|
||||||
|
@ -225,7 +247,7 @@ mod diff_tests {
|
||||||
Some(
|
Some(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
*Name:* Test
|
*Name:* Test
|
||||||
*Price:* 1 → 2"}
|
*Price:* 1 → 2 🔼"}
|
||||||
.into()
|
.into()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -275,7 +297,7 @@ mod diff_tests {
|
||||||
Some(
|
Some(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
*Name:* Test
|
*Name:* Test
|
||||||
*Stock:* 10 → 9"}
|
*Stock:* 10 → 9 🔽"}
|
||||||
.into()
|
.into()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue