rails-flog 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7573566571c52550bd3a1fdaf222159101caabb3
4
- data.tar.gz: 3e19ae5c1197155f93264ac7e28614bbd22596b6
3
+ metadata.gz: 37349e66f4eac2a3c918f1f5dd3a0575be741be1
4
+ data.tar.gz: 44b49c742fcf58e324a7406fa151c9b8248b0dde
5
5
  SHA512:
6
- metadata.gz: 1a196d239d1af127143e19eefb1e8526de7d32684baab1b301cbd4d16aacde126ef35235103cb0546b5fe6a17d5b3c4d207234c6de0d25e467032a964564e206
7
- data.tar.gz: b0b4ac38af5542776ea16fe73aa28efa774e2bee3b21618044c91c25de4d54ab13541099722039f4411f20dab9417874f7a22f92c36a49502c1b60ec661f116e
6
+ metadata.gz: 79f8fa25feaae28b230481ead671bdcfb8e4a6b7c367ddf255dd76e6e047e3f320b62f179e920aae46d9c96edc5aaf6501e59dc8d15260410c8b40e450a17de8
7
+ data.tar.gz: a51ab46561f273ffd74fe9c2cd50e1ac11e3e5c9e20a6af8b81721397a47531ef50b739568596a4aca7a4135e86297e7d14e997dd96ff92a3a95577fc9cdba45
data/README.md CHANGED
@@ -115,7 +115,8 @@ end
115
115
 
116
116
  ## Disable temporary
117
117
 
118
- If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable format.
118
+ If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable format.
119
+ Priority of this feature is higher than configurations.
119
120
 
120
121
  |File name |Feature |
121
122
  |:------------------|:----------|
@@ -143,4 +144,4 @@ If you put a file to `<rails_app>/tmp` direcotry, `rails-flog` will disable form
143
144
  - v1.1.1 (2013-12-06 JST): Change to alias_method_change from alias for method aliasing
144
145
  - v1.2.0 (2014-01-14 JST): Add feature that disables format partially by no-flog-sql.txt and no-flog-params.txt
145
146
  - v1.3.0 (2014-01-26 JST): Add configuration
146
-
147
+ - v1.3.1 (2014-01-27 JST): Refactored
@@ -41,10 +41,18 @@ class ActionController::LogSubscriber
41
41
  def formattable?(event)
42
42
  return false unless Flog::Status.params_formattable?
43
43
 
44
- if Flog.config.force_on_nested_params?
45
- return true if event.payload[:params].values.any? { |value| value.is_a?(Hash) }
46
- end
44
+ return true if force_format_by_nested_params?(event)
45
+
46
+ key_count_over?(event)
47
+ end
48
+
49
+ def force_format_by_nested_params?(event)
50
+ return false unless Flog.config.force_on_nested_params?
51
+
52
+ event.payload[:params].values.any? { |value| value.is_a?(Hash) }
53
+ end
47
54
 
55
+ def key_count_over?(event)
48
56
  threshold = Flog.config.params_key_count_threshold.to_i
49
57
  threshold += 1 if event.payload[:params].keys.include?("controller")
50
58
  threshold += 1 if event.payload[:params].keys.include?("action")
@@ -33,10 +33,16 @@ class ActiveRecord::LogSubscriber
33
33
  def formattable?(event)
34
34
  return false unless Flog::Status.sql_formattable?
35
35
 
36
- if event.payload[:name] == "CACHE" && Flog.config.ignore_cached_query?
37
- return false
38
- end
36
+ return false if ignore_by_cached_query?(event)
37
+
38
+ duration_over?(event)
39
+ end
40
+
41
+ def ignore_by_cached_query?(event)
42
+ event.payload[:name] == "CACHE" && Flog.config.ignore_cached_query?
43
+ end
39
44
 
45
+ def duration_over?(event)
40
46
  event.duration >= Flog.config.query_duration_threshold.to_f
41
47
  end
42
48
  end
data/lib/flog/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module Flog
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-flog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pinzolo