Skip to content

Commit

Permalink
fix: adds try except to continue syncronization (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
elitonzky authored Oct 13, 2023
1 parent b39e46c commit 60542d4
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions marketplace/wpp_products/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@ def sync_facebook_catalogs():
app.catalogs.values_list("facebook_catalog_id", flat=True)
)

response = client.list_all_catalogs(wa_business_id=wa_business_id)
try:
response = client.list_all_catalogs(wa_business_id=wa_business_id)
except Exception as e:
logger.error(f"Error listing all catalogs for app {app.uuid}: {str(e)}")
continue

fba_catalogs_ids = set(response)

to_create = fba_catalogs_ids - local_catalog_ids
to_delete = local_catalog_ids - fba_catalogs_ids

for catalog_id in to_create:
details = client.get_catalog_details(catalog_id)
try:
details = client.get_catalog_details(catalog_id)
except Exception as e:
logger.error(
f"Error getting catalog details for app {app.uuid}, catalog {catalog_id}: {str(e)}"
)
continue
try:
Catalog.objects.create(
app=app,
Expand All @@ -45,4 +56,10 @@ def sync_facebook_catalogs():
continue

if to_delete:
app.catalogs.filter(facebook_catalog_id__in=to_delete).delete()
try:
app.catalogs.filter(facebook_catalog_id__in=to_delete).delete()
except Exception as e:
logger.error(
f"Error deleting catalogs for app {app.uuid}: {str(e)}"
)
continue

0 comments on commit 60542d4

Please sign in to comment.