small updates

This commit is contained in:
tpv committed 2026-06-19 10:18:23 -07:00
1 parent 25632e1938
commit 965af7e4ee
5 files changed
+57 -16

No files matched your search

+4 -5
View File
@@ -55,20 +55,20 @@ async def add_products_to_database(
for product in products:
document = convert_product_to_mongo(product, category_identifier)
doc_id = document["_id"]
old_price = existing_prices.get(doc_id)
new_price = document.get("currentPrice")
price_dropped = old_price is None or (
new_price is not None and new_price < old_price
)
if price_dropped:
document["webhookSent"] = False
document["status"] = STATUS_PENDING
document["priceBeforeDrop"] = old_price
set_on_insert = {"discoveredDate": datetime.now(timezone.utc)}
if not price_dropped:
set_on_insert["webhookSent"] = False
set_on_insert["status"] = STATUS_PENDING
ops.append(
UpdateOne(
@@ -81,7 +81,7 @@ async def add_products_to_database(
try:
await collection.bulk_write(ops, ordered=False)
except PyMongoError:
LOGGER.exception(f"{category_identifier} - Failed to add products to database!")
LOGGER.exception(f"{category_identifier} - failed to add products to database")
raise
@@ -91,7 +91,6 @@ def convert_product_to_mongo(product: Product, category_identifier: str) -> dict
timing = data["timing"]
pricing = data["pricing"]
availability = data["availability"]
current_price = pricing["current_price"]
original_price = pricing["original_price"]
if isinstance(current_price, str):