From 43b23700c67766077419e7e21438b36d44511efc Mon Sep 17 00:00:00 2001 From: Eli Dickinson Date: Wed, 3 May 2017 15:44:53 -0400 Subject: [PATCH 1/2] Workaround for Sailthru blast API truncated (TECH-1615) See also Sailthru helpdesk issue https://sailthru.zendesk.com/hc/en-us/requests/257027?page=1 --- dive_sailthru_client/client.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dive_sailthru_client/client.py b/dive_sailthru_client/client.py index a810aec..aa403a1 100644 --- a/dive_sailthru_client/client.py +++ b/dive_sailthru_client/client.py @@ -165,6 +165,7 @@ def get_campaigns_in_range(self, start_date, end_date, list_name=None): 'status': 'sent', 'start_date': page_start_date.strftime("%Y-%m-%d"), 'end_date': page_end_date.strftime("%Y-%m-%d"), + 'limit': 999999, # workaround for limited data returned, see TECH-1615. } if list_name is not None: api_params['list'] = list_name @@ -172,9 +173,18 @@ def get_campaigns_in_range(self, start_date, end_date, list_name=None): result = self.api_get('blast', api_params) data = result.json + blasts = data.get('blasts', []) + filtered_count = data.get('filtered_count', 0) + # We discovered in TECH-1615 that Sailthru is (accidentally?) limiting number of results. So let's + # specifically raise an exception if the expected number of records doesn't match the actual returned. + if filtered_count != len(blasts): + raise SailthruApiError( + "Incomplete 'blast' API data. Expected %d records, got %d" % (filtered_count, len(blasts)) + ) + # We reverse the results to keep everything in ascending # chronological order. - for c in reversed(data.get('blasts', [])): + for c in reversed(blasts): c['dive_email_type'] = self._infer_dive_email_type(c) # technically below gets the pub, but keeping key `dive_brand` for backwards compatability c['dive_brand'] = self._infer_dive_publication(c) From b7ff94466185dbba2f4c9b39c0f22da9935f72d1 Mon Sep 17 00:00:00 2001 From: Eli Dickinson Date: Wed, 3 May 2017 15:46:30 -0400 Subject: [PATCH 2/2] bump version to 0.0.9 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6d514eb..d2b02c2 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="dive_sailthru_client", - version="0.0.8", + version="0.0.9", description="Industry Dive abstraction of the Sailthru API client", author='David Barbarisi', author_email='dbarbarisi@industrydive.com',