diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-14 09:58:18 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-14 09:58:18 +0000 |
commit | 9a2de028dc68525bead48a2c9d6aca21b0dc328a (patch) | |
tree | bb8d7c219958a7f8a172716e32692e1436c2f10b /activerecord | |
parent | 090bfcec60b89e7a4662733c705973642432583e (diff) | |
download | rails-9a2de028dc68525bead48a2c9d6aca21b0dc328a.tar.gz rails-9a2de028dc68525bead48a2c9d6aca21b0dc328a.tar.bz2 rails-9a2de028dc68525bead48a2c9d6aca21b0dc328a.zip |
Fix reconnect success rate to report as percentage. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3024 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 40ce6df618..9dbfe93cdf 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -25,7 +25,7 @@ module ActiveRecord @@reconnect_success = 0 @@reconnect_failure = 0 def self.reconnect_success_rate - @@reconnect_success.to_f / (@@reconnect_success + @@reconnect_failure) + (100.0 * @@reconnect_success / (@@reconnect_success + @@reconnect_failure)).to_i end def initialize(connection, logger = nil) #:nodoc: @@ -38,7 +38,7 @@ module ActiveRecord def adapter_name 'Abstract' end - + # Does this adapter support migrations? Backend specific, as the # abstract adapter always returns +false+. def supports_migrations? @@ -50,7 +50,7 @@ module ActiveRecord rt end - protected + protected def log(sql, name) if block_given? if @logger and @logger.level <= Logger::INFO @@ -110,11 +110,11 @@ module ActiveRecord reconnect! unless active? if active? @@reconnect_success += 1 - @logger.info "#{adapter_name} automatically reconnected. Success rate: #{'%.2f' % self.class.reconnect_success_rate}%" if @logger + @logger.info "#{adapter_name} automatically reconnected. Success rate: #{self.class.reconnect_success_rate}%" if @logger true else @@reconnect_failure += 1 - @logger.warn "#{adapter_name} automatic reconnection failed. Success rate: #{'%.2f' % self.class.reconnect_success_rate}%" if @logger + @logger.warn "#{adapter_name} automatic reconnection failed. Success rate: #{self.class.reconnect_success_rate}%" if @logger false end else |