From 5e8928e8dee542065a6d571d7e1eb952071c85dc Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 28 Oct 2022 10:41:42 +0530 Subject: [PATCH] fix: only log inventory sync failure in single log --- ecommerce_integrations/shopify/inventory.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ecommerce_integrations/shopify/inventory.py b/ecommerce_integrations/shopify/inventory.py index b1d1e3f9..a65dd94d 100644 --- a/ecommerce_integrations/shopify/inventory.py +++ b/ecommerce_integrations/shopify/inventory.py @@ -55,18 +55,19 @@ def upload_inventory_data_to_shopify(inventory_levels, warehous_map) -> None: update_inventory_sync_status(d.ecom_item, time=synced_on) d.status = "Success" except Exception as e: - create_shopify_log(method="update_inventory_on_shopify", status="Error", exception=e) d.status = "Failed" + d.failure_reason = str(e) _log_inventory_update_status(inventory_levels) def _log_inventory_update_status(inventory_levels) -> None: """Create log of inventory update.""" - log_message = "variant_id,location_id,status\n" + log_message = "variant_id,location_id,status,failure_reason\n" log_message += "\n".join( - f"{d.variant_id},{d.shopify_location_id},{d.status}" for d in inventory_levels + f"{d.variant_id},{d.shopify_location_id},{d.status},{d.failure_reason or ''}" + for d in inventory_levels ) stats = Counter([d.status for d in inventory_levels])