From: Ross Jones Date: Fri, 04 Jan 2013 13:50:21 +0000 Subject: Update to handle missing downloads data X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=fb2cf804c3fc7d54a87b987399d7aa4037c1c57e --- Update to handle missing downloads data --- --- a/ckanext/ga_report/download_analytics.py +++ b/ckanext/ga_report/download_analytics.py @@ -304,10 +304,14 @@ max_results=10000, end_date=end_date).execute() result_data = results.get('rows') + if not result_data: + # We may not have data for this time period, so we need to bail + # early. + log.info("There is no downloads data for this time period") + return + # [[url, count], [url],count] data = {} - if not result_data: - log.error(results) for result in result_data: data[result[0]] = data.get(result[0], 0) + int(result[1]) self._filter_out_long_tail(data, MIN_DOWNLOADS)