From: Tom Rees Date: Tue, 02 Apr 2013 16:25:45 +0000 Subject: [403] Fix rickshaw choking if there is an empty 'Others' series. X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=712b17e95c6b16fa6a688d274665b2d1701515ba --- [403] Fix rickshaw choking if there is an empty 'Others' series. --- --- a/ckanext/ga_report/controller.py +++ b/ckanext/ga_report/controller.py @@ -450,10 +450,11 @@ data.append(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/helpers.py +++ b/ckanext/ga_report/helpers.py @@ -80,7 +80,7 @@ return base.render_snippet('ga_report/ga_popular_single.html', **context) -def most_popular_datasets(publisher, count=20, preview_image=None): +def most_popular_datasets(publisher, count=20): if not publisher: _log.error("No valid publisher passed to 'most_popular_datasets'") @@ -92,8 +92,7 @@ 'dataset_count': len(results), 'datasets': results, - 'publisher': publisher, - 'preview_image': preview_image + 'publisher': publisher } return base.render_snippet('ga_report/publisher/popular.html', **ctx) --- a/ckanext/ga_report/templates/ga_report/ga_util.html +++ b/ckanext/ga_report/templates/ga_report/ga_util.html @@ -59,41 +59,21 @@ -
- - - Site-wide - | - Publishers - | - Datasets - -
- -
-
-
-

Download

-

- Download as CSV
-

-
-
-

Graph Legend

-
- -
-
-
-

Notes

-
    -
  • "Views" is the number of times a page was loaded in users' browsers.
  • -
  • "Downloads" is the number of times a user has clicked to download either an original or cached resource for a particular dataset. Download information is only available from 2nd December 2012; 'No data' is shown for records before that date.
  • -
  • These usage statistics are confined to users with javascript enabled, which excludes web crawlers and API calls.
  • -
  • The results are not shown when the number of views/visits is tiny. Where these relate to site pages, results are available in full in the CSV download. Where these relate to users' web browser information, results are not disclosed, for privacy reasons.
  • +
    +
    + -
    +
--- /dev/null +++ b/ckanext/ga_report/templates/ga_report/notes.html @@ -1,1 +1,16 @@ + +
  • +

    Notes

    +
      +
    • "Views" is the number of times a page was loaded in users' browsers.
    • +
    • "Downloads" is the number of times a user has clicked to download either an original or cached resource for a particular dataset. Download information is only available from 2nd December 2012; 'No data' is shown for records before that date.
    • +
    • These usage statistics are confined to users with javascript enabled, which excludes web crawlers and API calls.
    • +
    • The results are not shown when the number of views/visits is tiny. Where these relate to site pages, results are available in full in the CSV download. Where these relate to users' web browser information, results are not disclosed, for privacy reasons.
    • +
    +
  • + + --- a/ckanext/ga_report/templates/ga_report/publisher/index.html +++ b/ckanext/ga_report/templates/ga_report/publisher/index.html @@ -7,9 +7,19 @@ Usage by Publisher - - ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publisher_csv',month=c.month or 'all'))} +
  • +

    Download

    +

    + Download as CSV
    +

    +
  • +
  • +

    Graph Legend

    +
    +
    +
  • +
    @@ -25,12 +35,13 @@
    -

    Site Usage ${usage_nav('Publishers')}

    +

    Site Usage

    -
    + ${usage_nav('Publishers')} + ${rickshaw_graph(c.top_publishers_graph,'publishers')} -
    +
    ${month_selector(c.month, c.months, c.day)} @@ -38,21 +49,22 @@ - - - - + + + + - - - - + + + +
    PublisherDataset Views
    PublisherDataset 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}
    + ${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}
    -
    -
    + + +