From a47d0abd8ebb26147a854f7544792b93df5b8b8c Mon Sep 17 00:00:00 2001 From: Tudor Date: Wed, 26 Jul 2023 10:21:42 +0300 Subject: [PATCH] Fix mailchimp `mlist.members` iterations (#23) --- api/paul_api/plugin_mailchimp/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/paul_api/plugin_mailchimp/utils.py b/api/paul_api/plugin_mailchimp/utils.py index deff326..0f8bd37 100644 --- a/api/paul_api/plugin_mailchimp/utils.py +++ b/api/paul_api/plugin_mailchimp/utils.py @@ -334,10 +334,10 @@ def retrieve_lists_data(client: MailChimp): # # Sync list members list_members = client.lists.members.all(list_id=mlist['id'], get_all=True) - for member in list_members['members']: - list_members_creation_queue = [] - list_members_update_queue = [] + list_members_creation_queue = [] + list_members_update_queue = [] + for member in list_members['members']: member['audience_name'] = mlist['name'] audience_members_exists = Entry.objects.filter( table=audience_members_table, data__id=member['id'], data__audience_id=mlist['id']) @@ -406,8 +406,8 @@ def retrieve_lists_data(client: MailChimp): Entry.objects.bulk_update(list_members_update_queue, ["data"], batch_size=50) list_members_update_queue = [] - Entry.objects.bulk_create(list_members_creation_queue, batch_size=50) - Entry.objects.bulk_update(list_members_update_queue, ["data"], batch_size=50) + Entry.objects.bulk_create(list_members_creation_queue, batch_size=50) + Entry.objects.bulk_update(list_members_update_queue, ["data"], batch_size=50) return success, stats