rename monitor_name parameters to monitor

Applies to setup_monitor_logging, init_monitor, setup_config, get_config,
add_products_to_database and build_alert. Breaking for callers passing
monitor_name by keyword; every monitor repo is updated alongside.
This commit is contained in:
TPV committed 2026-09-25 19:02:09 -07:00
1 parent 401258f52a
commit ae637a134f
3 files changed
+21 -21

No files matched your search

+6 -6
View File
@@ -112,7 +112,7 @@ async def add_products_to_database(
products: list[Product],
collection: AsyncIOMotorCollection,
category_identifier: str,
monitor_name: str,
monitor: str,
use_composite: bool = False,
):
"""Upsert products, tracking deduplicated price history and emitting alerts.
@@ -138,7 +138,7 @@ async def add_products_to_database(
products: Products to upsert.
collection: Target MongoDB collection.
category_identifier: Category suffix appended to composite ids.
monitor_name: Monitor name stamped onto emitted alerts for consumer
monitor: Monitor name stamped onto emitted alerts for consumer
routing.
use_composite: Build composite ids so multi-variant monitors (Woot)
keep one doc per variant; other monitors collapse to one doc per
@@ -180,7 +180,7 @@ async def add_products_to_database(
never_seen_price = new_price is not None and new_price not in recorded_prices
set_on_insert = {"discoveredDate": now}
if existing_doc is None or never_seen_price:
alert = build_alert(monitor_name, document, now)
alert = build_alert(monitor, document, now)
alert_ops.append(
UpdateOne(
{"product_id": doc_id, "claimed": False},
@@ -279,7 +279,7 @@ def extract_recorded_prices(existing_doc: dict | None) -> set[float]:
return {entry["price"] for entry in existing_doc.get("pastPrices", [])}
def build_alert(monitor_name: str, document: dict, now: datetime) -> dict:
def build_alert(monitor: str, document: dict, now: datetime) -> dict:
"""Build an alert referencing a product for consumer delivery.
The alert carries its own copy of the document's newListing flag and
@@ -290,7 +290,7 @@ def build_alert(monitor_name: str, document: dict, now: datetime) -> dict:
and cannot rot.
Args:
monitor_name: Monitor that produced the product, used by the
monitor: Monitor that produced the product, used by the
consumer to resolve the owning collection and thresholds.
document: Product document supplying the id, pricing for the
priority calculation, and the stamped newListing flag and
@@ -302,7 +302,7 @@ def build_alert(monitor_name: str, document: dict, now: datetime) -> dict:
"""
return {
"monitor": monitor_name,
"monitor": monitor,
"product_id": document["_id"],
"priority": calculate_priority(document),
"claimed": False,