aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-04-30 17:30:15 +0100
committerGareth Rees <gareth@mysociety.org>2015-05-07 15:53:14 +0100
commit67d69ce1f8f81f44c0099e631d0ba95fc02d9763 (patch)
tree22162ec544438d2cf03136d9f4bf4d485b5bf2b4
parent45093b0b6d01b784c4725a000c17055b6f0373fa (diff)
Reduce N+1 queries getting new body requests
Removes the following Bullet warnings: N+1 Query detected PublicBodyChangeRequest => [:public_body] Add to your finder: :includes => [:public_body] N+1 Query method call stack /home/vagrant/alaveteli/app/models/public_body_change_request.rb:65:in `get_public_body_name' /home/vagrant/alaveteli/app/views/admin_general/_change_request_summary.html .erb:8:in `_app_views_admin_general__change_request_summary_html_erb__490351475_701155 42681500' /home/vagrant/alaveteli/app/views/admin_general/index.html.erb:191:in `_app_views_admin_general_index_html_erb___48164640_70115537288900' /home/vagrant/alaveteli/app/views/admin_general/index.html.erb:190:in `_app_views_admin_general_index_html_erb___48164640_70115537288900' /home/vagrant/alaveteli/app/controllers/application_controller.rb:111:in `record_memory' /home/vagrant/alaveteli/lib/whatdotheyknow/strip_empty_sessions.rb:14:in `call' N+1 Query detected PublicBodyChangeRequest => [:user] Add to your finder: :includes => [:user] N+1 Query method call stack /home/vagrant/alaveteli/app/models/public_body_change_request.rb:57:in `get_user_name' /home/vagrant/alaveteli/app/views/admin_general/_change_request_summary.html .erb:46:in `_app_views_admin_general__change_request_summary_html_erb__490351475_701155 42681500' /home/vagrant/alaveteli/app/views/admin_general/index.html.erb:191:in `_app_views_admin_general_index_html_erb___48164640_70115537288900' /home/vagrant/alaveteli/app/views/admin_general/index.html.erb:190:in `_app_views_admin_general_index_html_erb___48164640_70115537288900' /home/vagrant/alaveteli/app/controllers/application_controller.rb:111:in `record_memory' /home/vagrant/alaveteli/lib/whatdotheyknow/strip_empty_sessions.rb:14:in `call'
-rw-r--r--app/controllers/admin_general_controller.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb
index 3eaabda81..35f872666 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -31,7 +31,10 @@ class AdminGeneralController < AdminController
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
- @new_body_requests = PublicBodyChangeRequest.new_body_requests.open
+ @new_body_requests = PublicBodyChangeRequest.
+ includes(:public_body, :user).
+ new_body_requests.
+ open
@body_update_requests = PublicBodyChangeRequest.body_update_requests.open
end