Sha256: 3e35535f9624bd1dca7e2ef22b6f1f21b1079165726a4d27601b598d26390727

Contents?: true

Size: 387 Bytes

Versions: 27

Compression:

Stored size: 387 Bytes

Contents

module ActiveRecord
  class QueryCounter
    attr_reader :query_count

    def initialize
      @query_count = 0
    end

    def to_proc
      lambda(&method(:callback))
    end

    def callback(name, start, finish, message_id, values)
      @query_count += 1 unless %w(CACHE SCHEMA).include?(values[:name]) || values[:sql] =~ /^begin/i || values[:sql] =~ /^commit/i
    end
  end
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
ledermann-rails-settings-2.5.0 spec/support/query_counter.rb
rails-properties-3.4.3 spec/support/query_counter.rb
ledermann-rails-settings-2.4.3 spec/support/query_counter.rb
unread-0.10.0 spec/support/query_counter.rb
unread-0.9.1 spec/support/query_counter.rb
unread-0.9.0 spec/support/query_counter.rb
unread-0.8.3 spec/support/query_counter.rb
unread-0.8.2 spec/support/query_counter.rb
unread-0.8.1 spec/support/query_counter.rb
ledermann-rails-settings-2.4.2 spec/support/query_counter.rb
unread-0.8.0 spec/support/query_counter.rb
ledermann-rails-settings-2.4.1 spec/support/query_counter.rb
unread-0.7.1 spec/support/query_counter.rb
unread-0.7.0 spec/support/query_counter.rb
unread-0.6.3 spec/support/query_counter.rb
unread-0.6.2 spec/support/query_counter.rb
unread-0.6.1 spec/support/query_counter.rb
unread-0.6.0 spec/support/query_counter.rb
ledermann-rails-settings-2.4.0 spec/support/query_counter.rb
unread-0.5.0 spec/support/query_counter.rb