diff options
author | Mark Longair <mhl@pobox.com> | 2013-10-15 13:38:25 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-10-15 13:57:45 +0100 |
commit | 7e1ed07ea7f6448b1fada769e04b0369fdd0a222 (patch) | |
tree | 83c3bb621ddd18b58b14700fc337c5c2717daf5e | |
parent | 18cded9d726bfb8002b4be0cb1312a0b9905debc (diff) |
Only include minimal information about public bodies in JSON
Previously, the JSON included all the columns from the public
body table, which was unnecessary and included the public body's
email address. Instead, just include the name and URL of the
public body.
-rw-r--r-- | app/controllers/public_body_controller.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 1f7032eed..f52b77a13 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -251,6 +251,11 @@ 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 = { 'id' => "#{column}-#{highest ? 'highest' : 'lowest'}", 'x_axis' => _('Public Bodies'), @@ -261,7 +266,7 @@ class PublicBodyController < ApplicationController if data data_to_draw.update(data) data_to_draw['x_values'] = data['public_bodies'].each_with_index.map { |pb, i| i } - data_to_draw['x_ticks'] = data['public_bodies'].each_with_index.map { |pb, i| [i, pb.name] } + data_to_draw['x_ticks'] = data['public_bodies'].each_with_index.map { |pb, i| [i, pb['name']] } end @graph_list.push data_to_draw |