Public Access
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:
@@ -259,6 +259,9 @@ class LuckyCaliforniaScraper:
|
||||
promo = price_block.get("promoArea") or {}
|
||||
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
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user