From: Ross Jones Date: Thu, 01 Nov 2012 12:20:09 +0000 Subject: Changes related to presentation, and new tabs. X-Git-Url: https://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=057d00a6cf3c01b4116652d18a545db65974868d --- Changes related to presentation, and new tabs. - Changed nearly all values to percentages of the total - Added non-version info for OS and browsers - Made tabs into dropdowns for Browser/OS --- --- a/ckanext/ga_report/controller.py +++ b/ckanext/ga_report/controller.py @@ -76,8 +76,14 @@ mins, secs = divmod(float(val), 60) hours, mins = divmod(mins, 60) val = '%02d:%02d:%02d (%s seconds) ' % (hours, mins, secs, val) + if key == 'Percent new visits': + key = 'New visits' + val = "%s%%" % val if key in ['Bounces', 'Total pageviews']: val = int(val) + if key == 'Total pageviews': + key = 'Total page views' + return key, val c.global_totals = [] @@ -99,8 +105,10 @@ c.global_totals = sorted(c.global_totals, key=operator.itemgetter(0)) keys = { - 'Browser versions': 'browsers', - 'Operating Systems versions': 'os', + 'Browser versions': 'browser_versions', + 'Browsers': 'browsers', + 'Operating Systems versions': 'os_versions', + 'Operating Systems': 'os', 'Social sources': 'social_networks', 'Languages': 'languages', 'Country': 'country' @@ -143,9 +151,14 @@ entries.append((key,val,)) entries = sorted(entries, key=operator.itemgetter(1), reverse=True) - setattr(c, v, [(k,v) for k,v in entries ]) - - + def percent(num, total): + p = 100 * float(num)/float(total) + return "%.2f%%" % round(p, 2) + + # Get the total for each set of values and then set the value as + # a percentage of the total + total = sum([num for _,num in entries]) + setattr(c, v, [(k,percent(v,total)) for k,v in entries ]) return render('ga_report/site/index.html') --- a/ckanext/ga_report/templates/ga_report/ga_util.html +++ b/ckanext/ga_report/templates/ga_report/ga_util.html @@ -12,6 +12,20 @@ ${title} + + + + + + + + + + + + + +
Name% Views
${name}${value}
--- a/ckanext/ga_report/templates/ga_report/site/index.html +++ b/ckanext/ga_report/templates/ga_report/site/index.html @@ -44,8 +44,22 @@
-
- - - - - - - - - - - -
NameValue
${name}${value}
-
-
- - - - - - - - - - - -
NameValue
${name}${value}
-
+
+ ${stat_table(c.browser_versions)} +
+
+ ${stat_table(c.browsers)} +
+
+ ${stat_table(c.os)} +
+
+ ${stat_table(c.os_versions)} +
- - - - - - - - - - - -
NameValue
${name}${value}
+ ${stat_table(c.social_networks)}
- - - - - - - - - - - -
NameValue
${name}${value}
+ ${stat_table(c.languages)}
- - - - - - - - - - - -
NameValue
${name}${value}
+ ${stat_table(c.country)}
@@ -148,6 +113,7 @@