Skip to content

Commit d218d23

Browse files
committed
fix: message formatting
1 parent 9d63b4c commit d218d23

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

aio_etsy_stats/main.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,17 @@ def __init__(self, shop: str, default_reset_hour: int = 14, scrape_interval_minu
9999
else:
100100
self.logger.debug(f"Initial Stats were returned okay. Example... sold {stats.sold_count}")
101101

102-
self.logger.info(textwrap.dedent(f"""
102+
message = textwrap.dedent(f"""
103103
{type(self).__name__} for **{self.shop}**
104104
105105
-# Scraping for store metrics on host `{socket.gethostname()}`
106106
-# Public IP is `{get_public_ip()}`
107107
-# Scraping using Selenium Chrome
108-
-# Scrapes run about every {self.scrape_interval_minutes} minutes
109-
""").strip())
108+
-# Scrapes run about every **{self.scrape_interval_minutes}** minutes
109+
""").strip()
110+
if bool(environ.get("DEV_LOVE_NOTE", "0")):
111+
message += "\n-# *Shawn ❤️ Nicole*"
112+
self.logger.info(message.strip())
110113

111114
# region Setup AIO
112115
if not all([aio_username, aio_password]):
@@ -301,18 +304,22 @@ def _reset_counts(self) -> None:
301304
if new_reset_datetime < datetime.now():
302305
# Just incase you start this app after the current day's reset timer hit
303306
new_reset_datetime = self.reset_datetime + timedelta(days=1)
304-
self.logger.info(textwrap.dedent(f"""
307+
message = textwrap.dedent(f"""
305308
{type(self).__name__} for **{self.shop}**
306309
307310
-# Reset time of **{self.reset_datetime:%Y-%m-%d %H:%M:%S%z}** has passed
308-
-# Daily Order Count was `{self.daily_order_count}`
309-
-# Daily Favorites was `{self.favorite_count - self.starting_favorite_count}`
310-
-# Daily Rating was `{(self.rating - self.starting_rating):4f}`
311-
-# Daily Rating Count was `{self.rating_count - self.starting_rating_count}`
312-
-# Daily Sold was `{self.sold_count - self.starting_sold_count}`
311+
-# Daily Order Count was **{self.daily_order_count}**
312+
-# Daily Favorites was **{self.favorite_count - self.starting_favorite_count}**
313+
-# Daily Rating was **{(self.rating - self.starting_rating):4f}**
314+
-# Daily Rating Count was **{self.rating_count - self.starting_rating_count}**
315+
-# Daily Sold was **{self.sold_count - self.starting_sold_count}**
313316
-# Next reset is **{new_reset_datetime:%Y-%m-%d %H:%M:%S%z}**
314317
-# Public IP is `{get_public_ip()}`
315-
""").strip())
318+
""").strip()
319+
if bool(environ.get("DEV_LOVE_NOTE", "0")):
320+
message += "\n-# *Shawn ❤️ Nicole*"
321+
self.logger.info(message.strip())
322+
316323

317324
# Update all things to be equal to current stats
318325
self.reset_datetime = new_reset_datetime
@@ -468,7 +475,7 @@ def collect_and_publish(self) -> None:
468475
self.logger.info(textwrap.dedent(f"""
469476
Favorites for **{self.shop}**
470477
471-
-# Count changed `{self.favorite_count:,}` -> `{stats.favorite_count:,}`
478+
-# Count changed **{self.favorite_count:,}** -> **{stats.favorite_count:,}**
472479
""").strip())
473480
self.favorite_count = stats.favorite_count
474481
self._send_aio(feed="favorite-count", value=self.favorite_count)
@@ -480,17 +487,17 @@ def collect_and_publish(self) -> None:
480487
message = textwrap.dedent(f"""
481488
Rating for **{self.shop}**
482489
483-
-# Count changed `{self.rating_count:,}` -> `{stats.rating_count:,}`
490+
-# Count changed **{self.rating_count:,}** -> **{stats.rating_count:,}**
484491
""").strip()
485492
self.rating_count = stats.rating_count
486493
self._send_aio(feed="rating-count", value=self.rating_count)
487494

488495
# If rating did not change, do not say it did
489496
rating_change = round((stats.rating - self.rating), 4)
490497
if rating_change == 0.0:
491-
message += f"\n-# Overall is `{self.rating:.4f}`"
498+
message += f"\n-# Overall is **{self.rating:.4f}**"
492499
else:
493-
message += f"\n-# Overall changed `{self.rating:.4f}` -> `{stats.rating:.4f}`"
500+
message += f"\n-# Overall changed **{self.rating:.4f}** -> **{stats.rating:.4f}**"
494501
self.rating = stats.rating
495502
self._send_aio(feed="rating", value=self.rating)
496503

@@ -507,15 +514,15 @@ def collect_and_publish(self) -> None:
507514
message = textwrap.dedent(f"""
508515
Orders for **{self.shop}**
509516
510-
-# Sold Count changed `{self.sold_count:,}` -> `{stats.sold_count:,}`
517+
-# Sold Count changed **{self.sold_count:,}** -> **{stats.sold_count:,}**
511518
""").strip()
512519
if self.sold_count < stats.sold_count:
513-
message += f"\n-# Daily Order Count changed from `{self.daily_order_count:,}` -> " \
514-
f"`{(self.daily_order_count + 1):,}`"
520+
message += f"\n-# Daily Order Count changed from **{self.daily_order_count:,}** -> " \
521+
f"**{(self.daily_order_count + 1):,}**"
515522
self.daily_order_count += 1
516523
self._send_aio(feed="daily-order-count", value=self.daily_order_count)
517524
else:
518-
message += f"\n-# Daily Order Count is `{self.daily_order_count:,}`"
525+
message += f"\n-# Daily Order Count is **{self.daily_order_count:,}**"
519526
self.logger.info(message.strip())
520527

521528
self.sold_count = stats.sold_count

0 commit comments

Comments
 (0)