8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/debugbar/subscribers/active_record.rb', line 8
def sql(event)
return if Debugbar::Current.ignore?
payload = event.payload
return if payload[:name]&.starts_with? "SCHEMA"
title = if payload[:async]
"ASYNC #{payload[:name]} (#{payload[:lock_wait].round(1)}ms) (db time #{event.duration.round(1)}ms)"
else
"#{payload[:name] || "Unnamed"} (#{event.duration.round(1)}ms)"
end
title = "CACHE #{title}" if payload[:cached]
sql = payload[:sql]&.gsub(/\/\*.*\*\//, "")
binds = nil
Debugbar::Tracker.add_query({
id: event.transaction_id,
title: title,
name: payload[:name],
sql: sql,
cached: payload[:cached].present?,
async: payload[:async],
duration: event.duration.round(1),
lock_wait: payload[:lock_wait]&.round(1),
binds: binds,
source: query_source_location
})
end
|