Fixing two bugs in one, making sure All are deleted as well as period and fixing a string concat problem
--- a/ckanext/ga_report/ga_model.py
+++ b/ckanext/ga_report/ga_model.py
@@ -161,10 +161,13 @@
def pre_update_url_stats(period_name):
+ log.debug("Deleting '%s' records" % period_name)
model.Session.query(GA_Url).\
filter(GA_Url.period_name==period_name).delete()
+ log.debug("Deleting 'All' records")
model.Session.query(GA_Url).\
- filter(GA_Url.period_name=='All').delete()
+ filter(GA_Url.period_name == 'All').delete()
+ model.repo.commit_and_remove()
def update_url_stats(period_name, period_complete_day, url_data):
@@ -216,8 +219,8 @@
'period_name': 'All',
'period_complete_day': 0,
'url': url,
- 'pageviews': sum([int(e.pageviews) for e in entries]) + old_pageviews,
- 'visits': sum([int(e.visits or 0) for e in entries]) + old_visits,
+ 'pageviews': sum([int(e.pageviews) for e in entries]) + int(old_pageviews),
+ 'visits': sum([int(e.visits or 0) for e in entries]) + int(old_visits),
'department_id': publisher,
'package_id': package
}
@@ -343,7 +346,7 @@
'''
for object_type in (GA_Url, GA_Stat, GA_Publisher, GA_ReferralStat):
q = model.Session.query(object_type)
- if period_name != 'all':
+ if period_name != 'All':
q = q.filter_by(period_name=period_name)
q.delete()
model.Session.commit()
--- a/ckanext/ga_report/templates/ga_report/notes.html
+++ b/ckanext/ga_report/templates/ga_report/notes.html
@@ -5,7 +5,6 @@
<li class="widget-container boxed widget_text">
<h4>Notes</h4>
- <hr/>
<ul>
<li>"Views" is the number of times a page was loaded in users' browsers.</li>
<li>"Visits" is the number of unique user visits to a page, counted once for each visitor for each of their browsing sessions.</li>
--- a/ckanext/ga_report/templates/ga_report/publisher/index.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/index.html
@@ -10,7 +10,6 @@
<py:match path="primarysidebar">
<li class="widget-container boxed widget_text">
<h4>Download</h4>
- <hr/>
<p><center>
<a class="btn button btn-primary" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publisher_csv',month=c.month or 'all')}">Download as CSV</a></center>
</p>
@@ -38,14 +37,13 @@
<table class="table table-condensed table-bordered table-striped">
<tr>
<th>Publisher</th>
-<!-- <th>Dataset Visits</th>-->
<th>Dataset Views</th>
</tr>
<py:for each="publisher, views, visits in c.top_publishers">
<tr>
- <td>${h.link_to(publisher.title, h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport', action='read_publisher', id=publisher.name) + ("?month=" + c.month) if c.month else '')}
+ <td>
+ ${h.link_to(publisher.title, h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport', action='read_publisher', id=publisher.name) + (("?month=" + c.month) if c.month else ''))}
</td>
-<!-- <td>${visits}</td> -->
<td>${views}</td>
</tr>
</py:for>
--- a/ckanext/ga_report/templates/ga_report/publisher/read.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/read.html
@@ -10,7 +10,6 @@
<py:match path="primarysidebar">
<li class="widget-container boxed widget_text">
<h4>Download</h4>
- <hr/>
<p><center>
<a class="btn button btn-primary" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='dataset_csv',id=c.publisher_name or 'all',month=c.month or 'all')}">Download as CSV</a></center>
</p>
--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -10,7 +10,6 @@
<py:match path="primarysidebar">
<li class="widget-container boxed widget_text">
<h4>Download</h4>
- <hr/>
<p><center>
<a class="btn button btn-primary" href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='csv',month=c.month or 'all')}">Download as CSV</a></center>
</p>