diff options
author | Mark Longair <mhl@pobox.com> | 2013-10-31 14:54:04 +0000 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-10-31 14:54:04 +0000 |
commit | a290c82bdd7369af61b4a5266768382a1755ad1a (patch) | |
tree | 937c41399a483c0d3c3386a0b551d4e7b39af89e | |
parent | 78b3f77968b3621f7f307b3f2764563f74c923c6 (diff) |
Avoid an error when the statistics column hasn't been populated
The 'if data' needs to be earlier to avoid an error if one of the
statistics columns hasn't been filled in by the
stats:update_public_bodies_stats rake task yet.
Thanks to Louise Crow for pointing this out in code review.
-rw-r--r-- | app/controllers/public_body_controller.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 505325df3..3eb02c4f8 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -251,21 +251,21 @@ class PublicBodyController < ApplicationController minimum_requests) end - # We just need the URL and name of each public body: - data['public_bodies'].map! { |pb| - {'name' => pb.name, 'url' => public_body_path(pb)} - } - - data_to_draw = Hash.new { |h, k| h[k] = [] } - data_to_draw.update({ - 'id' => "#{column}-#{highest ? 'highest' : 'lowest'}", - 'x_axis' => _('Public Bodies'), - 'y_axis' => graph_properties[:y_axis], - 'errorbars' => percentages, - 'title' => graph_properties[:title] - }) - if data + # We just need the URL and name of each public body: + data['public_bodies'].map! { |pb| + {'name' => pb.name, 'url' => public_body_path(pb)} + } + + data_to_draw = Hash.new { |h, k| h[k] = [] } + data_to_draw.update({ + 'id' => "#{column}-#{highest ? 'highest' : 'lowest'}", + 'x_axis' => _('Public Bodies'), + 'y_axis' => graph_properties[:y_axis], + 'errorbars' => percentages, + 'title' => graph_properties[:title] + }) + data_to_draw.update(data) data['public_bodies'].each_with_index { |pb, i| data_to_draw['x_values'].push i |