From: Tom Rees Date: Thu, 14 Feb 2013 12:52:31 +0000 Subject: [162] Assertions were overzealous. Code can handle more broken data now. X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=fd18a9580e09c28b7010e6f735756ac29526138d --- [162] Assertions were overzealous. Code can handle more broken data now. --- --- a/ckanext/ga_report/controller.py +++ b/ckanext/ga_report/controller.py @@ -417,11 +417,14 @@ # Create a consistent x-axis between all series num_points = [ len(series['data']) for series in data ] ideal_index = num_points.index( max(num_points) ) - x_axis = [ point['x'] for point in data[ideal_index]['data'] ] + x_axis = [] + for series in data: + for point in series['data']: + x_axis.append(point['x']) + x_axis = sorted( list( set(x_axis) ) ) + # Zero pad any missing values for series in data: xs = [ point['x'] for point in series['data'] ] - assert set(xs).issubset( set(x_axis) ), (xs, x_axis) - # Zero pad any missing values for x in set(x_axis).difference(set(xs)): series['data'].append( {'x':x, 'y':0} ) if percentageMode: @@ -430,9 +433,6 @@ for series in series_list: for point in series['data']: totals[point['x']] = totals.get(point['x'],0) + point['y'] - lengths = [ len(series['data']) for series in series_list ] - assert len(set(lengths))==1 - assert lengths[0] == len(totals) return totals # Transform data into percentage stacks totals = get_totals(data) --- a/ckanext/ga_report/public/css/ga_report.css +++ b/ckanext/ga_report/public/css/ga_report.css @@ -45,3 +45,7 @@ width: 200px; } +.ga-reports-table .td-numeric { + text-align: center; +} + --- a/ckanext/ga_report/templates/ga_report/ga_util.html +++ b/ckanext/ga_report/templates/ga_report/ga_util.html @@ -14,7 +14,7 @@ - +
@@ -24,7 +24,7 @@ - +
Name Source
${name} ${source}${count}${count}
@@ -45,15 +45,15 @@ - +
- + - +
Name% ${title}% ${title}
${name}${value}${value}
@@ -63,12 +63,13 @@
--- a/ckanext/ga_report/templates/ga_report/publisher/index.html +++ b/ckanext/ga_report/templates/ga_report/publisher/index.html @@ -48,17 +48,17 @@
- +
- + - +
PublisherDataset ViewsDataset 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 ''))} ${views}${views}
--- a/ckanext/ga_report/templates/ga_report/publisher/read.html +++ b/ckanext/ga_report/templates/ga_report/publisher/read.html @@ -62,7 +62,7 @@ - +
@@ -73,8 +73,8 @@ - - + +
Dataset Views ${h.link_to(package.title or package.name, h.url_for(controller='package', action='read', id=package.name))} ${views}${downloads}${views}${downloads}
--- a/ckanext/ga_report/templates/ga_report/site/index.html +++ b/ckanext/ga_report/templates/ga_report/site/index.html @@ -71,16 +71,16 @@
- +
- + - +
NameValueValue History
${name}${value}${value} ${','.join([y for x,y in graph])}