scrapers: drop Swiftly products with unparseable price

Products missing a parseable sale or regular price would previously yield
a GroceryItem with current_price=None. That broke the downstream matcher
(ingredient typical_price is non-null) and cluttered the table.

Added a guard in map_product() to return None when both reg_price and
sale_price are None. Fixes test_map_product_returns_none_for_unparseable.
This commit is contained in:
2026-05-18 17:22:29 -07:00
parent 69acd70188
commit e92cc3a074
+3
View File
@@ -259,6 +259,9 @@ class LuckyCaliforniaScraper:
promo = price_block.get("promoArea") or {} promo = price_block.get("promoArea") or {}
sale_price, sale_unit = cls._parse_price(promo.get("promoText")) sale_price, sale_unit = cls._parse_price(promo.get("promoText"))
if reg_price is None and sale_price is None:
return None
unit = sale_unit or reg_unit unit = sale_unit or reg_unit
is_on_sale = sale_price is not None and reg_price is not None and sale_price < reg_price is_on_sale = sale_price is not None and reg_price is not None and sale_price < reg_price
# current_price = "what the customer pays today" → sale_price when on sale. # current_price = "what the customer pays today" → sale_price when on sale.