From: Ross Jones
Date: Thu, 06 Dec 2012 16:30:31 +0000
Subject: Updated count of deleted records
X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=25c791cfcf26848e6b6b8cf12e81b7997c7363cb
---
Updated count of deleted records
---
--- a/ckanext/ga_report/ga_model.py
+++ b/ckanext/ga_report/ga_model.py
@@ -161,10 +161,20 @@
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()
- model.Session.query(GA_Url).\
- filter(GA_Url.period_name=='All').delete()
+
+ count = model.Session.query(GA_Url).\
+ filter(GA_Url.period_name == 'All').count()
+ log.debug("Deleting %d 'All' records" % count)
+ count = model.Session.query(GA_Url).\
+ filter(GA_Url.period_name == 'All').delete()
+ log.debug("Deleted %d 'All' records" % count)
+
+ model.Session.flush()
+ model.Session.commit()
+ model.repo.commit_and_remove()
def update_url_stats(period_name, period_complete_day, url_data):
@@ -216,8 +226,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,10 +353,10 @@
'''
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()
+ model.repo.commit_and_remove()
def get_score_for_dataset(dataset_name):
'''
--- a/ckanext/ga_report/templates/ga_report/notes.html
+++ b/ckanext/ga_report/templates/ga_report/notes.html
@@ -5,7 +5,6 @@
Notes
-
- "Views" is the number of times a page was loaded in users' browsers.
- "Visits" is the number of unique user visits to a page, counted once for each visitor for each of their browsing sessions.
--- a/ckanext/ga_report/templates/ga_report/publisher/index.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/index.html
@@ -10,7 +10,6 @@
-
Download
-
Download as CSV
@@ -38,14 +37,13 @@
Publisher |
-
Dataset Views |
- ${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 '')}
+ |
+ ${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 ''))}
|
-
${views} |
--- a/ckanext/ga_report/templates/ga_report/publisher/read.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/read.html
@@ -10,7 +10,6 @@
Download
-
Download as CSV
--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -10,7 +10,6 @@
Download
-
Download as CSV