diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-22 12:08:07 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-22 12:08:07 -0700 |
commit | 8c19ebe5539fae896a1a6fb2549e9e63445b6607 (patch) | |
tree | 602e64ddac2fbbfd487ca7b558cefc5a7fcd1e8d /activerecord/lib | |
parent | 4ee7d923e1962bec68d56c565d574672dce5b692 (diff) | |
parent | 60b55baca9e381deb3a0a85580f089f4caf551d4 (diff) | |
download | rails-8c19ebe5539fae896a1a6fb2549e9e63445b6607.tar.gz rails-8c19ebe5539fae896a1a6fb2549e9e63445b6607.tar.bz2 rails-8c19ebe5539fae896a1a6fb2549e9e63445b6607.zip |
Merge pull request #1219 from fcheung/db_time_fix
Take into account time spent in AR even if a redirect occurs or if it is
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/railties/controller_runtime.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/railties/controller_runtime.rb b/activerecord/lib/active_record/railties/controller_runtime.rb index fb3fd34665..44efb384fc 100644 --- a/activerecord/lib/active_record/railties/controller_runtime.rb +++ b/activerecord/lib/active_record/railties/controller_runtime.rb @@ -23,8 +23,8 @@ module ActiveRecord db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime runtime = super db_rt_after_render = ActiveRecord::LogSubscriber.reset_runtime - self.db_runtime = db_rt_before_render + db_rt_after_render - runtime - db_rt_after_render + self.db_runtime = db_rt_before_render + db_during_render + runtime - db_during_render else super end @@ -32,7 +32,9 @@ module ActiveRecord def append_info_to_payload(payload) super - payload[:db_runtime] = db_runtime + if ActiveRecord::Base.connected? + payload[:db_runtime] = (db_runtime || 0) + ActiveRecord::LogSubscriber.reset_runtime + end end module ClassMethods |