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.
@@ -15,15 +15,19 @@ module DbDebug
15
15
 
16
16
  module ClassMethods
17
17
  def find_by_sql_with_record_counter(*args)
18
- resp = nil
19
- request.env['db.count'] = request.env['db.count'] + 1
20
- time = Benchmark.realtime { resp = find_by_sql_without_record_counter(*args) } * 1000
21
- if request.params[:db_debug]
22
- Logger.log :white, "DB Query took: #{time} ms"
23
- Logger.log :white, caller.delete_if{ |str| str.include?("/gems/") || str.include?("script/rails") }.join("\n")
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
 
@@ -1,3 +1,3 @@
1
1
  module DbDebug
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: