Class: Dblint::RailsIntegration

Inherits:
Object
  • Object
show all
Defined in:
lib/dblint/rails_integration.rb

Constant Summary collapse

CHECKS =
[
  Dblint::Checks::LongHeldLock,
  Dblint::Checks::MissingIndex
]

Instance Method Summary collapse

Instance Method Details

#check_instance_for_connection(connid, klass) ⇒ Object



10
11
12
13
14
# File 'lib/dblint/rails_integration.rb', line 10

def check_instance_for_connection(connid, klass)
  @checks ||= {}
  @checks[connid] ||= {}
  @checks[connid][klass] ||= klass.new
end

#finish(name, id, payload) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/dblint/rails_integration.rb', line 25

def finish(name, id, payload)
  return if %w(CACHE DBLINT SCHEMA).include?(payload[:name])

  CHECKS.each do |check_klass|
    check = check_instance_for_connection(payload[:connection_id], check_klass)
    check.statement_finished(name, id, payload)
  end
end

#start(name, id, payload) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/dblint/rails_integration.rb', line 16

def start(name, id, payload)
  return if %w(CACHE DBLINT SCHEMA).include?(payload[:name])

  CHECKS.each do |check_klass|
    check = check_instance_for_connection(payload[:connection_id], check_klass)
    check.statement_started(name, id, payload)
  end
end