File: n_plus_one_query.rb

package info (click to toggle)
ruby-bullet 7.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 836 kB
  • sloc: ruby: 6,133; javascript: 57; sh: 27; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 646 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module Bullet
  module Notification
    class NPlusOneQuery < Base
      def initialize(callers, base_class, associations, path = nil)
        super(base_class, associations, path)

        @callers = callers
      end

      def body
        "#{klazz_associations_str}\n  Add to your query: #{associations_str}"
      end

      def title
        "USE eager loading #{@path ? "in #{@path}" : 'detected'}"
      end

      def notification_data
        super.merge(backtrace: [])
      end

      protected

      def call_stack_messages
        (['Call stack'] + @callers).join("\n  ")
      end
    end
  end
end