prosopite 1.1.4 → 1.2.0

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
  SHA256:
3
- metadata.gz: df639c665fefc84471086093056a2588fa173b81c66ac43e332fba52ba536408
4
- data.tar.gz: f2fee55c16bf971f4cbba8d6b522ed097f807590024d5ec386ab8fc8f5b7b984
3
+ metadata.gz: ee61188281e95718d5a0b8faf642f6db6356befb1b126ede3f6fe26a032b0ba9
4
+ data.tar.gz: 78596f3e5de98c354631229752fe42f3d682646782a3d633e24260100b7b4113
5
5
  SHA512:
6
- metadata.gz: d57e66ffe211db8c38a7188e23bc5d82aa1f30b78e0ae1564831a8fe51f85dd7f9a0a8f1c09d619d2c8754bd2dde93d6b9b1bdc95399aa215daee98a0be697f0
7
- data.tar.gz: 4a621d14b33c5943038fcc401b2d8caaa49767ffa4b3c3de5df2316dc452ae80c106c4d1150718d5318a8ee9e866903fc4b7767a32f2d288d62e35485ede182d
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.4)
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.4"
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]
@@ -83,7 +91,7 @@ module Prosopite
83
91
  tc[:prosopite_notifications] = {}
84
92
 
85
93
  tc[:prosopite_query_counter].each do |location_key, count|
86
- if count > 1
94
+ if count >= @min_n_queries
87
95
  fingerprints = tc[:prosopite_query_holder][location_key].map do |q|
88
96
  begin
89
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.4
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-10-18 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