added has_msrp for no msrp based products(new lists)

This commit is contained in:
TPV committed 2026-08-04 10:04:32 -07:00
1 parent 2e6e7ebc69
commit 61c4887c38
3 files changed
+11 -1

No files matched your search

+1
View File
@@ -358,6 +358,7 @@ def convert_product_to_mongo(product: Product) -> dict:
"endDate": timing["end_date"], "endDate": timing["end_date"],
"priceBeforeDrop": pricing["price_before_drop"], "priceBeforeDrop": pricing["price_before_drop"],
"eduPrice": pricing["edu_price"], "eduPrice": pricing["edu_price"],
"hasMsrp": pricing["has_msrp"],
"available": availability["available"], "available": availability["available"],
"availabilityLastChecked": availability["availability_last_checked"], "availabilityLastChecked": availability["availability_last_checked"],
"condition": availability["condition"], "condition": availability["condition"],
+1
View File
@@ -62,6 +62,7 @@ class PricingInfo:
price_before_drop: float | None = None price_before_drop: float | None = None
edu_price: float | None = None edu_price: float | None = None
past_prices: list[dict] | None = None past_prices: list[dict] | None = None
has_msrp: bool = True
@dataclass @dataclass
+9 -1
View File
@@ -167,6 +167,10 @@ def build_product_details(
product_id = product["_id"] product_id = product["_id"]
current_price = product["currentPrice"] current_price = product["currentPrice"]
original_price = product["originalPrice"] original_price = product["originalPrice"]
percentage = 0
has_msrp = product["has_msrp"]
if has_msrp:
if not original_price: if not original_price:
LOGGER.warning( LOGGER.warning(
"missing or zero original price, skipping", "missing or zero original price, skipping",
@@ -179,7 +183,10 @@ def build_product_details(
# A percentage code compounds onto the sale price, so an item can clear the # A percentage code compounds onto the sale price, so an item can clear the
# threshold on the combined discount even when the base discount would not. # threshold on the combined discount even when the base discount would not.
# Dollar codes do not map to a percent and never affect the threshold. # Dollar codes do not map to a percent and never affect the threshold.
effective_percentage = combined_discount(percentage, product.get("promoPercentage"))
effective_percentage = combined_discount(
percentage, product.get("promoPercentage")
)
passes_percentage = effective_percentage >= min_percentage passes_percentage = effective_percentage >= min_percentage
passes_price_drop = min_price_drop is not None and price_drop >= min_price_drop passes_price_drop = min_price_drop is not None and price_drop >= min_price_drop
if not passes_percentage and not passes_price_drop: if not passes_percentage and not passes_price_drop:
@@ -212,6 +219,7 @@ def build_product_details(
price_before_drop=product["priceBeforeDrop"], price_before_drop=product["priceBeforeDrop"],
edu_price=product["eduPrice"], edu_price=product["eduPrice"],
past_prices=product["pastPrices"], past_prices=product["pastPrices"],
has_msrp=has_msrp,
), ),
availability=AvailabilityInfo( availability=AvailabilityInfo(
available=product["available"], available=product["available"],