Exception: NOne::NPlusOneDetected

Inherits:
StandardError
  • Object
show all
Defined in:
lib/n_one.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ NPlusOneDetected

Returns a new instance of NPlusOneDetected.



10
11
12
13
# File 'lib/n_one.rb', line 10

def initialize(report)
  @report = report
  super
end

Instance Method Details

#messageObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/n_one.rb', line 15

def message
  "N+1 queries detected(count: #{@report.size}) \n" +
    @report.map do |detected_case|
      <<~MESSAGE
        SQL query called #{detected_case[:count]} times
        ---
        #{detected_case[:sql].join("\n")}

        Backtrace:
        ---
        #{detected_case[:caller].join("\n")}
      MESSAGE
    end.join("\n\n")
end