[403] Fix rickshaw choking if there is an empty 'Others' series.
--- a/ckanext/ga_report/controller.py
+++ b/ckanext/ga_report/controller.py
@@ -218,7 +218,10 @@
'x':_get_unix_epoch(stat.period_name),
'y':float(stat.value)
})
- graph = [ graph_dict[x[0]] for x in entries ]
+ stats_in_table = [x[0] for x in entries]
+ stats_not_in_table = set(graph_dict.keys()) - set(stats_in_table)
+ stats = stats_in_table + sorted(list(stats_not_in_table))
+ graph = [graph_dict[x] for x in stats]
setattr(c, v+'_graph', json.dumps( _to_rickshaw(graph,percentageMode=True) ))
# Get the total for each set of values and then set the value as
@@ -445,12 +448,13 @@
fraction = float(point['y']) / totals[point['x']]
if not (series in data) and fraction>THRESHOLD:
data.append(series)
- # Overwrite data with a set of intereting series
+ # Overwrite data with a set of interesting series
others = [ x for x in raw_data if not (x in data) ]
- data.append({
- 'name':'Other',
- 'data': [ {'x':x,'y':y} for x,y in get_totals(others).items() ]
- })
+ if len(others):
+ data.append({
+ 'name':'Other',
+ 'data': [ {'x':x,'y':y} for x,y in get_totals(others).items() ]
+ })
# Turn each point into a percentage
for series in data:
for point in series['data']:
--- a/ckanext/ga_report/templates/ga_report/ga_util.html
+++ b/ckanext/ga_report/templates/ga_report/ga_util.html
@@ -59,15 +59,21 @@
</table>
-<div py:def="usage_nav(active_name)">
- <span class="subheading">
- <img src="/images/arrow-down-right.png" />
- <a class="${if_(active_name=='Site-wide','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}${if_(c.month,'?month='+c.month)}">Site-wide</a>
- <span class="divider">|</span>
- <a class="${if_(active_name=='Publishers','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}${if_(c.month,'?month='+c.month)}">Publishers</a>
- <span class="divider">|</span>
- <a class="${if_(active_name=='Datasets','active')}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}${if_(c.month,'?month='+c.month)}">Datasets</a>
- </span>
+<div py:def="usage_nav(active_name)" id="minornavigation">
+ <div id="minornavigation-bg-left">
+ <div id="minornavigation-bg-right">
+ <ul class="nav nav-pills">
+ <?python querystring='?month='+c.month if c.month else '' ?>
+ <li py:attrs="{'class': 'active' if active_name=='Site-wide' else None}"><a py:attrs="{'class': 'active' if active_name=='Site-wide' else None}" href="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='index')}${querystring}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Site-wide</a></li>
+ <li py:attrs="{'class': 'active' if active_name=='Publishers' else None}">
+ <a py:attrs="{'class': 'active' if active_name=='Publishers' else None}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}${querystring}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Publishers</a>
+ </li>
+ <li py:attrs="{'class': 'active' if active_name=='Datasets' else None}">
+ <a py:attrs="{'class': 'active' if active_name=='Datasets' else None}" href="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='read')}${querystring}"><img src="/images/icons/page_white.png" height="16px" width="16px" alt="None" class="inline-icon "/> Datasets</a>
+ </li>
+ </ul>
+ </div>
+ </div>
</div>
--- a/ckanext/ga_report/templates/ga_report/publisher/index.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/index.html
@@ -6,8 +6,6 @@
<xi:include href="../ga_util.html" />
<py:def function="page_title">Usage by Publisher</py:def>
-
- <py:def function="content_class"><!----></py:def>
<py:match path="primarysidebar">
<li class="widget-container boxed widget_text">
@@ -37,12 +35,13 @@
<div py:match="content">
- <h1>Site Usage ${usage_nav('Publishers')}</h1>
+ <h1>Site Usage</h1>
- <div class="boxed">
+ ${usage_nav('Publishers')}
+
${rickshaw_graph(c.top_publishers_graph,'publishers')}
- <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}" method="get">
+ <form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publishers')}" method="get">
<div class="controls">
<label>Show stats table for:</label>
${month_selector(c.month, c.months, c.day)}
@@ -50,21 +49,22 @@
</form>
<table class="ga-reports-table table table-condensed table-bordered table-striped">
- <tr>
- <th>Publisher</th>
- <th class="td-numeric">Dataset Views</th>
- </tr>
+ <tr>
+ <th>Publisher</th>
+ <th class="td-numeric">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>
- <td class="td-numeric">${views}</td>
- </tr>
+ <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>
+ <td class="td-numeric">${views}</td>
+ </tr>
</py:for>
</table>
- </div><!--/boxed-->
- </div><!--/content-->
+
+
+ </div>
<py:def function="optional_footer">
<script type="text/javascript">
--- a/ckanext/ga_report/templates/ga_report/publisher/read.html
+++ b/ckanext/ga_report/templates/ga_report/publisher/read.html
@@ -6,8 +6,6 @@
<xi:include href="../ga_util.html" />
<py:def function="page_title">Usage by Dataset</py:def>
-
- <py:def function="content_class"><!----></py:def>
<py:def function="optional_head">
<link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
@@ -37,9 +35,11 @@
<div py:match="content">
- <h1>Site Usage ${usage_nav('Datasets')}</h1>
+ <h1>Site Usage</h1>
- <div class="boxed">
+ ${usage_nav('Datasets')}
+
+
<h3 py:if="c.publisher"><a href="${h.url_for(controller='ckanext.dgu.controllers.publisher:PublisherController',action='read',id=c.publisher.name)}">${c.publisher.title}</a></h3>
<p py:if="not c.top_packages">No page views in this period</p>
@@ -80,7 +80,6 @@
</table>
</py:if>
- </div>
</div>
--- a/ckanext/ga_report/templates/ga_report/site/downloads.html
+++ b/ckanext/ga_report/templates/ga_report/site/downloads.html
@@ -6,8 +6,6 @@
<xi:include href="../ga_util.html" />
<py:def function="page_title">Downloads</py:def>
-
- <py:def function="content_class"><!----></py:def>
<py:match path="primarysidebar">
<li py:if="c.downloads" class="widget-container boxed widget_text">
@@ -21,9 +19,8 @@
</py:match>
<div py:match="content">
- <h1>Downloads ${usage_nav('Downloads')}</h1>
-
- <div class="boxed">
+ <h1>Downloads</h1>
+ ${usage_nav('Downloads')}
<form class="form-inline" action="${h.url_for(controller='ckanext.ga_report.controller:GaReport',action='downloads')}" method="get">
<div class="controls">
@@ -41,7 +38,6 @@
<h4>No data</h4>
<p>There is no download data available for this month</p>
</py:if>
- </div>
</div>
<xi:include href="../../layout.html" />
--- a/ckanext/ga_report/templates/ga_report/site/index.html
+++ b/ckanext/ga_report/templates/ga_report/site/index.html
@@ -6,8 +6,6 @@
<xi:include href="../ga_util.html" />
<py:def function="page_title">Site usage</py:def>
-
- <py:def function="content_class"><!----></py:def>
<py:def function="optional_head">
<link rel="stylesheet" type="text/css" href="/scripts/vendor/rickshaw.min.css"/>
@@ -38,9 +36,9 @@
</py:match>
<div py:match="content">
- <h1>Site Usage ${usage_nav('Site-wide')}</h1>
+ <h1>Site Usage</h1>
+ ${usage_nav('Site-wide')}
- <div class="boxed">
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active"><a href="#totals" data-toggle="hashtab">Totals</a></li>
@@ -164,7 +162,6 @@
</div>
</div>
</div>
- </div>
</div>