db_debug 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/db_debug/active_record.rb +12 -8
- data/lib/db_debug/version.rb +1 -1
- metadata +1 -1
@@ -15,15 +15,19 @@ module DbDebug
|
|
15
15
|
|
16
16
|
module ClassMethods
|
17
17
|
def find_by_sql_with_record_counter(*args)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
if defined? request
|
19
|
+
resp = nil
|
20
|
+
request.env['db.count'] = request.env['db.count'] + 1
|
21
|
+
time = Benchmark.realtime { resp = find_by_sql_without_record_counter(*args) } * 1000
|
22
|
+
if request.params[:db_debug]
|
23
|
+
Logger.log :white, "DB Query took: #{time} ms"
|
24
|
+
Logger.log :white, caller.delete_if{ |str| str.include?("/gems/") || str.include?("script/rails") }.join("\n")
|
25
|
+
end
|
26
|
+
request.env['db.time'] = request.env['db.time'] + time
|
27
|
+
resp
|
28
|
+
else
|
29
|
+
find_by_sql_without_record_counter(*args)
|
24
30
|
end
|
25
|
-
request.env['db.time'] = request.env['db.time'] + time
|
26
|
-
resp
|
27
31
|
end
|
28
32
|
end
|
29
33
|
|
data/lib/db_debug/version.rb
CHANGED