Sha256: b9c3cf3dd5aa5004e3d2449a0d8b3503d7f9568d61328777b2db0d14c798430a
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require "n_plus_one_control/version" require "n_plus_one_control/executor" # RSpec and Minitest matchers to prevent N+1 queries problem. module NPlusOneControl class << self attr_accessor :default_scale_factors, :verbose, :ignore, :event def failure_message(queries) msg = ["Expected to make the same number of queries, but got:\n"] queries.each do |(scale, data)| msg << " #{data.size} for N=#{scale}\n" msg << data.map { |sql| " #{sql}\n" }.join.to_s if verbose end msg.join end end # Scale factors to use. # Use the smallest possible but representative scale factors by default. self.default_scale_factors = [2, 3] # Print performed queries if true self.verbose = false # Ignore matching queries self.ignore = /^(BEGIN|COMMIT|SAVEPOINT|RELEASE)/ # ActiveSupport notifications event to track queries. # We track ActiveRecord event by default, # but can also track rom-rb events ('sql.rom') as well. self.event = 'sql.active_record' end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
n_plus_one_control-0.1.1 | lib/n_plus_one_control.rb |
n_plus_one_control-0.1.0 | lib/n_plus_one_control.rb |
n_plus_one_control-0.0.3 | lib/n_plus_one_control.rb |