prosopite 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9c5dea23442e0babd58c4dd220938d01fc9460eb759810814ec7a09143e2b12
4
- data.tar.gz: 36dc15cd352b25fa0376c8318d947ea52107cd8c98c5095c8756f5081828579e
3
+ metadata.gz: ee61188281e95718d5a0b8faf642f6db6356befb1b126ede3f6fe26a032b0ba9
4
+ data.tar.gz: 78596f3e5de98c354631229752fe42f3d682646782a3d633e24260100b7b4113
5
5
  SHA512:
6
- metadata.gz: fcb0974923a1923042352dfd23d237784518c026eda52c798b562024c6bd16b2a6b9e6eb02ebe585f23cfa71faee134e1a4a652f17b304a5f657c4ec813ef872
7
- data.tar.gz: 9d379efacd427a3e20d6fb071aea080243a8bac90c759d88f13cac6461951bc1a57d39f43572a0575d60945692f0f29df6776be7659bf1411a1bda303aefcd8d
6
+ metadata.gz: 4d0b66d7d06563f6832008f0191ce68041d050c0d46d7baee591aead407d5e5789b08056cac7e1aa09034494c11ac84672b3163b831a3338a8483fd44f7262d4
7
+ data.tar.gz: 651de4487b98786ba0de927e1b9edef804b7d40037a2c54cf2a007e8e74cf1ee84abd6bde9fad9997bfb8f04fce13d2c063ffe27c479d578f0f487a82c299acf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prosopite (1.1.3)
4
+ prosopite (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -115,6 +115,7 @@ Or install it yourself as:
115
115
 
116
116
  The preferred type of notifications can be configured with:
117
117
 
118
+ * `Prosopite.min_n_queries`: Minimum number of N queries to report per N+1 case. Defaults to 2.
118
119
  * `Prosopite.raise = true`: Raise warnings as exceptions
119
120
  * `Prosopite.rails_logger = true`: Send warnings to the Rails log
120
121
  * `Prosopite.prosopite_logger = true`: Send warnings to `log/prosopite.log`
@@ -269,6 +270,8 @@ end
269
270
  Prosopite.finish
270
271
  ```
271
272
 
273
+ Pauses can be ignored with `Prosopite.ignore_pauses = true` in case you want to remember their N+1 queries.
274
+
272
275
  An example of when you might use this is if you are [testing Active Jobs inline](https://guides.rubyonrails.org/testing.html#testing-jobs),
273
276
  and don't want to run Prosopite on background job code, just foreground app code. In that case you could write an [Active Job callback](https://edgeguides.rubyonrails.org/active_job_basics.html#callbacks) that pauses the scan while the job is running.
274
277
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prosopite
4
- VERSION = "1.1.3"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/prosopite.rb CHANGED
@@ -10,7 +10,9 @@ module Prosopite
10
10
  :prosopite_logger,
11
11
  :custom_logger,
12
12
  :allow_stack_paths,
13
- :ignore_queries
13
+ :ignore_queries,
14
+ :ignore_pauses,
15
+ :min_n_queries
14
16
 
15
17
  def allow_list=(value)
16
18
  puts "Prosopite.allow_list= is deprecated. Use Prosopite.allow_stack_paths= instead."
@@ -29,6 +31,8 @@ module Prosopite
29
31
  tc[:prosopite_query_caller] = {}
30
32
 
31
33
  @allow_stack_paths ||= []
34
+ @ignore_pauses ||= false
35
+ @min_n_queries ||= 2
32
36
 
33
37
  tc[:prosopite_scan] = true
34
38
 
@@ -48,6 +52,10 @@ module Prosopite
48
52
  end
49
53
 
50
54
  def pause
55
+ if @ignore_pauses
56
+ return block_given? ? yield : nil
57
+ end
58
+
51
59
  if block_given?
52
60
  begin
53
61
  previous = tc[:prosopite_scan]
@@ -66,7 +74,8 @@ module Prosopite
66
74
  end
67
75
 
68
76
  def scan?
69
- tc[:prosopite_scan]
77
+ !!(tc[:prosopite_scan] && tc[:prosopite_query_counter] &&
78
+ tc[:prosopite_query_holder] && tc[:prosopite_query_caller])
70
79
  end
71
80
 
72
81
  def finish
@@ -82,7 +91,7 @@ module Prosopite
82
91
  tc[:prosopite_notifications] = {}
83
92
 
84
93
  tc[:prosopite_query_counter].each do |location_key, count|
85
- if count > 1
94
+ if count >= @min_n_queries
86
95
  fingerprints = tc[:prosopite_query_holder][location_key].map do |q|
87
96
  begin
88
97
  fingerprint(q)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prosopite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mpampis Kostas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-29 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry