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) 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',