aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_general_controller.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-05-01 10:01:31 +0100
committerGareth Rees <gareth@mysociety.org>2015-05-07 15:53:14 +0100
commit8068b389a0c3118eeb13148021bd064b9226a9e3 (patch)
tree3c297810990bad9b6eddeba12c68d21fa1134907 /app/controllers/admin_general_controller.rb
parent730f8c6affd5d847323bb78770cfca443ae6890f (diff)
Reduce N+1 queries getting holding pen requests
Removes the following bullet warning: N+1 Query detected IncomingMessage => [:raw_email] Add to your finder: :includes => [:raw_email] N+1 Query method call stack /home/vagrant/alaveteli/app/models/incoming_message.rb:115:in `parse_raw_email!' /home/vagrant/alaveteli/app/models/incoming_message.rb:150:in `sent_at' /home/vagrant/alaveteli/app/views/admin_general/index.html.erb:54:in `_app_views_admin_general_index_html_erb___48164640_70115534664600' /home/vagrant/alaveteli/app/views/admin_general/index.html.erb:42:in `_app_views_admin_general_index_html_erb___48164640_70115534664600' /home/vagrant/alaveteli/app/controllers/application_controller.rb:111:in `record_memory' /home/vagrant/alaveteli/lib/whatdotheyknow/strip_empty_sessions.rb:14:in `call' Improved view rendering times: Before: Completed 200 OK in 2813.9ms (Views: 1697.3ms | ActiveRecord: 9.5ms) Completed 200 OK in 2548.6ms (Views: 1838.2ms | ActiveRecord: 8.2ms) After: Completed 200 OK in 2185.9ms (Views: 276.0ms | ActiveRecord: 7.5ms) Completed 200 OK in 2216.3ms (Views: 100.3ms | ActiveRecord: 7.6ms)
Diffstat (limited to 'app/controllers/admin_general_controller.rb')
-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 d5838f2da..7034fa17d 100644
--- a/app/controllers/admin_general_controller.rb
+++ b/app/controllers/admin_general_controller.rb
@@ -30,7 +30,10 @@ class AdminGeneralController < AdminController
select { |pb| !pb.defunct? }
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
- @holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
+ @holding_pen_messages = InfoRequest.
+ includes(:incoming_messages => :raw_email).
+ holding_pen_request.
+ incoming_messages
@new_body_requests = PublicBodyChangeRequest.
includes(:public_body, :user).
new_body_requests.