Skip to content

Commit

Permalink
fix: only log inventory sync failure in single log
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Oct 28, 2022
1 parent 7ea6d15 commit 5e8928e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ecommerce_integrations/shopify/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 5e8928e

Please sign in to comment.