optimize product enrichment by avoiding duplicate product processing

This commit is contained in:
2025-09-17 14:38:41 +03:00
parent e9a10d1ac0
commit 0122fd2b0c

View File

@ -293,7 +293,11 @@ async def additional_deals_data(*deals: dict, full: bool):
deal["services"] = enriched_services
enriched_products = []
selected = set()
for product in deal.get("products", []):
product_id = product["productId"]
if product_id in selected:
continue
if full:
product["product"] = products.get(product["productId"])
@ -305,6 +309,8 @@ async def additional_deals_data(*deals: dict, full: bool):
total_price += service.get("price", 0) * service.get("quantity", 1) * product.get("quantity", 1)
product["services"] = enriched_services
selected.add(product_id)
enriched_products.append(product)
total_products += product.get("quantity", 1)