From: Ross Jones Date: Thu, 08 Nov 2012 15:05:53 +0000 Subject: Merge branch 'master' of github.com:datagovuk/ckanext-ga-report X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=49977fd394b2f3dc62e6eb513d43897b81bae0bc --- Merge branch 'master' of github.com:datagovuk/ckanext-ga-report --- --- a/ckanext/ga_report/controller.py +++ b/ckanext/ga_report/controller.py @@ -232,7 +232,7 @@ return render('ga_report/publisher/index.html') def _get_packages(self, publisher=None, count=-1): - '''Returns the datasets in order of visits''' + '''Returns the datasets in order of views''' if count == -1: count = sys.maxint @@ -244,7 +244,7 @@ if publisher: q = q.filter(GA_Url.department_id==publisher.name) q = q.filter(GA_Url.period_name==month) - q = q.order_by('ga_url.visits::int desc') + q = q.order_by('ga_url.pageviews::int desc') top_packages = [] for entry,package in q.limit(count): if package: @@ -329,7 +329,7 @@ def _get_publishers(): ''' Returns a list of all publishers. Each item is a tuple: - (names, title) + (name, title) ''' publishers = [] for pub in model.Session.query(model.Group).\ --- a/ckanext/ga_report/ga_model.py +++ b/ckanext/ga_report/ga_model.py @@ -343,3 +343,21 @@ q.delete() model.Session.commit() +def get_score_for_dataset(dataset_name): + import datetime + now = datetime.datetime.now() + period_names = ['%s-%02d' % (now.year, now.month), + '%s-%02d' % (now.year, now.month-1)] + + entry = model.Session.query(GA_Url)\ + .filter(GA_Url.period_name==period_names[0])\ + .filter(GA_Url.package_id==dataset_name).first() + score = int(entry.pageviews) if entry else 0 + + entry = model.Session.query(GA_Url)\ + .filter(GA_Url.period_name==period_names[1])\ + .filter(GA_Url.package_id==dataset_name).first() + val = int(entry.pageviews) if entry else 0 + score += val/2 if val else 0 + + return 0 --- a/ckanext/ga_report/templates/ga_report/notes.html +++ b/ckanext/ga_report/templates/ga_report/notes.html @@ -6,8 +6,8 @@
  • Notes