From: Ross Jones Date: Wed, 23 Jan 2013 10:26:11 +0000 Subject: Makes sure we don't add (and log) when we can't find the dataset for popular, fixes #242 X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=bba4b4bb39795e575708868f9c0edce3adbdd7ed --- Makes sure we don't add (and log) when we can't find the dataset for popular, fixes #242 --- --- a/ckanext/ga_report/helpers.py +++ b/ckanext/ga_report/helpers.py @@ -106,6 +106,10 @@ for entry in entries: if len(datasets) < count: p = model.Package.get(entry.url[len('/dataset/'):]) + if not p: + _log.warning("Could not find Package for {url}".format(url=entry.url)) + continue + if not p in datasets: datasets[p] = {'views':0, 'visits': 0} datasets[p]['views'] = datasets[p]['views'] + int(entry.pageviews)