diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/public_body_controller.rb | 34 | ||||
-rw-r--r-- | app/controllers/track_controller.rb | 3 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 2 | ||||
-rw-r--r-- | app/models/public_body.rb | 39 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/views/public_body/statistics.html.erb | 6 |
6 files changed, 51 insertions, 35 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index 1f7032eed..494e19353 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -201,7 +201,7 @@ class PublicBodyController < ApplicationController raise ActiveRecord::RecordNotFound.new("Page not enabled") end - per_graph = 8 + per_graph = 10 minimum_requests = AlaveteliConfiguration::minimum_requests_for_statistics # Make sure minimum_requests is > 0 to avoid division-by-zero minimum_requests = [minimum_requests, 1].max @@ -251,20 +251,30 @@ class PublicBodyController < ApplicationController minimum_requests) end - data_to_draw = { - '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_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] } - end + data['public_bodies'].each_with_index { |pb, i| + data_to_draw['x_values'].push i + data_to_draw['x_ticks'].push [i, pb['name']] + data_to_draw['tooltips'].push pb['name'] + } - @graph_list.push data_to_draw + @graph_list.push data_to_draw + end end end diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 40fa69290..72c092221 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -181,7 +181,8 @@ class TrackController < ApplicationController if new_medium == 'delete' track_thing.destroy flash[:notice] = _("You are no longer following {{track_description}}.", :track_description => track_thing.params[:list_description]) - redirect_to params[:r] + redirect_to URI.parse(params[:r]).path + # Reuse code like this if we let medium change again. #elsif new_medium == 'email_daily' # track_thing.track_medium = new_medium diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index e2ee696c5..6efc1d2ba 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -12,6 +12,8 @@ # last_sent_at :datetime # incoming_message_followup_id :integer # what_doing :string(255) not null +# prominence :string(255) default("normal"), not null +# prominence_reason :text # # models/outgoing_message.rb: diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 485a794b0..9e77eb181 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -3,23 +3,26 @@ # # Table name: public_bodies # -# id :integer not null, primary key -# name :text not null -# short_name :text not null -# request_email :text not null -# version :integer not null -# last_edit_editor :string(255) not null -# last_edit_comment :text not null -# created_at :datetime not null -# updated_at :datetime not null -# url_name :text not null -# home_page :text default(""), not null -# notes :text default(""), not null -# first_letter :string(255) not null -# publication_scheme :text default(""), not null -# api_key :string(255) not null -# info_requests_count :integer default(0), not null -# disclosure_log :text default(""), not null +# id :integer not null, primary key +# name :text not null +# short_name :text not null +# request_email :text not null +# version :integer not null +# last_edit_editor :string(255) not null +# last_edit_comment :text not null +# created_at :datetime not null +# updated_at :datetime not null +# url_name :text not null +# home_page :text default(""), not null +# notes :text default(""), not null +# first_letter :string(255) not null +# publication_scheme :text default(""), not null +# api_key :string(255) not null +# info_requests_count :integer default(0), not null +# disclosure_log :text default(""), not null +# info_requests_successful_count :integer +# info_requests_not_held_count :integer +# info_requests_overdue_count :integer # require 'csv' @@ -407,6 +410,8 @@ class PublicBody < ActiveRecord::Base fields = {} field_names.each{|name, i| fields[name] = row[i]} + yield line, fields if block_given? + name = row[field_names['name']] email = row[field_names['request_email']] next if name.nil? diff --git a/app/models/user.rb b/app/models/user.rb index d7c1c854e..2c4f87944 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,8 +20,6 @@ # email_bounce_message :text default(""), not null # no_limit :boolean default(FALSE), not null # receive_email_alerts :boolean default(TRUE), not null -# address :string(255) -# dob :date # require 'digest/sha1' diff --git a/app/views/public_body/statistics.html.erb b/app/views/public_body/statistics.html.erb index 840af0c10..6ea253260 100644 --- a/app/views/public_body/statistics.html.erb +++ b/app/views/public_body/statistics.html.erb @@ -52,9 +52,9 @@ are due to him.") %></p> </tr> </thead> <tbody> - <% graph_data['x_ticks'].each_with_index do |pb_and_index, i| %> + <% graph_data['public_bodies'].each_with_index do |pb, i| %> <tr> - <td><%= pb_and_index[1] %></td> + <td><%= link_to pb['name'], pb['url'] %></td> <td class="statistic"><%= graph_data['y_values'][i].round %></td> </tr> <% end %> @@ -70,6 +70,6 @@ are due to him.") %></p> var graphs_data = <%= @graph_list.to_json.html_safe %>; </script> <!--[if lte IE 8]><%= javascript_include_tag 'excanvas.min.js' %><![endif]--> -<%= javascript_include_tag 'jquery.flot.min.js', 'jquery.flot.errorbars.min.js', 'jquery.flot.axislabels.js', 'stats-graphs.js' %> +<%= javascript_include_tag 'jquery.flot.min.js', 'jquery.flot.errorbars.min.js', 'jquery.flot.tickrotor.min.js', 'jquery.flot.axislabels.min.js', 'stats-graphs.js' %> </div> |