From: Ross Jones Date: Thu, 13 Jun 2013 09:02:37 +0000 Subject: [601] Make sure only active datasets are shown in popular datasets on publisher homepage X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=e1cf709a3d29cfdac40e8dcee1d67e703c4e70fa --- [601] Make sure only active datasets are shown in popular datasets on publisher homepage --- --- a/ckanext/ga_report/helpers.py +++ b/ckanext/ga_report/helpers.py @@ -107,12 +107,18 @@ 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.state == 'active': + _log.warning("Package {0} is not active, it is {1}".format(p.name, p.state)) + continue + if not p in datasets: datasets[p] = {'views':0, 'visits': 0} + datasets[p]['views'] = datasets[p]['views'] + int(entry.pageviews) datasets[p]['visits'] = datasets[p]['visits'] + int(entry.visits)