prosopite 2.1.2 → 2.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: 0fa7674935ab767fc5eb216492948abd724d07b2a720d345a6da361a51e80efe
4
- data.tar.gz: 23b72eae523301b0b95d244577a019a266420fb4dc1560751b965ad6c57ea517
3
+ metadata.gz: 3ba705386994a5f73eb64b024eadd45fd4c29db669ccc408283746d03d58bdf8
4
+ data.tar.gz: b3d52ea151dd88b9da262286df321fcdafd2245ce3b09c9539fd54e9ae54ee8d
5
5
  SHA512:
6
- metadata.gz: 804e8468b23f1a6e3911a28932fb643d67aa2a5a9dc0d55662307b9ce8f412ff60c5ed3a0aded37bfa17f5dd6634f121132758f3997555147495f5ceed2a9beb
7
- data.tar.gz: 120685a04d3a23e45b5cb6b14a8b544e40aeec4329e750156df91b3c42f4b51ce71ab1a26d28f9fb6334656a694337a58da51fa848ee46ea8341c2135e9c0b73
6
+ metadata.gz: e6f74f6cd59e7537429f32300072394c428837e3ec0dd8aed971d601f447c0f3b28e2bdd68f240f98906be205d23958c3cdd8cbf181821cc26f4f435de5f17c8
7
+ data.tar.gz: 570b9ed4965908b45b5f1f5d6dc1b41d84e0b00759c93e1ff875aa181f143c445ec910ad96dfb4c52ba2020e4948660fc203d3ff8cd8c7496bc870acf0df8180
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prosopite (2.1.2)
4
+ prosopite (2.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -329,6 +329,7 @@ class ApplicationController < ActionController::Base
329
329
  end
330
330
  end
331
331
  ```
332
+
332
333
  ```ruby
333
334
  # app/controllers/books_controller.rb
334
335
  class BooksController < ApplicationController
@@ -343,6 +344,7 @@ class BooksController < ApplicationController
343
344
  @book.reviews.map(&:author) # This will not raise N+1 errors
344
345
  end
345
346
  end
347
+ ```
346
348
 
347
349
  ## Custom Logging Configuration
348
350
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prosopite
4
- VERSION = "2.1.2"
4
+ VERSION = "2.2.0"
5
5
  end
data/lib/prosopite.rb CHANGED
@@ -51,6 +51,7 @@ module Prosopite
51
51
  tc[:prosopite_query_counter] = Hash.new(0)
52
52
  tc[:prosopite_query_holder] = Hash.new { |h, k| h[k] = [] }
53
53
  tc[:prosopite_query_caller] = {}
54
+ tc[:prosopite_query_duration] = Hash.new(0.0)
54
55
 
55
56
  @allow_stack_paths ||= []
56
57
  @ignore_pauses ||= false
@@ -111,6 +112,7 @@ module Prosopite
111
112
  tc[:prosopite_query_counter] = nil
112
113
  tc[:prosopite_query_holder] = nil
113
114
  tc[:prosopite_query_caller] = nil
115
+ tc[:prosopite_query_duration] = nil
114
116
  end
115
117
 
116
118
  def start_raise
@@ -151,8 +153,9 @@ module Prosopite
151
153
  is_allowed = kaller.any? { |f| allow_list.any? { |s| f.match?(s) } }
152
154
 
153
155
  unless is_allowed
156
+ duration_ms = tc[:prosopite_query_duration][location_key]
154
157
  queries.each do |q|
155
- tc[:prosopite_notifications][q] = kaller
158
+ tc[:prosopite_notifications][q] = { kaller: kaller, duration_ms: duration_ms }
156
159
  end
157
160
  end
158
161
  end
@@ -231,8 +234,12 @@ module Prosopite
231
234
 
232
235
  notifications_str = String.new('')
233
236
 
234
- tc[:prosopite_notifications].each do |queries, kaller|
235
- notifications_str << "N+1 queries detected:\n"
237
+ tc[:prosopite_notifications].each do |queries, info|
238
+ kaller = info[:kaller]
239
+ duration_ms = info[:duration_ms]
240
+ time_str = duration_ms ? " (#{duration_ms.round(1)}ms)" : ''
241
+
242
+ notifications_str << "N+1 queries detected#{time_str}:\n"
236
243
 
237
244
  queries.each { |q| notifications_str << " #{q}\n" }
238
245
 
@@ -272,7 +279,7 @@ module Prosopite
272
279
  @subscribed ||= false
273
280
  return if @subscribed
274
281
 
275
- ActiveSupport::Notifications.subscribe 'sql.active_record' do |_, _, _, _, data|
282
+ ActiveSupport::Notifications.subscribe 'sql.active_record' do |_, start, finish, _, data|
276
283
  sql, name = data[:sql], data[:name]
277
284
 
278
285
  if scan? && name != "SCHEMA" && sql.include?('SELECT') && data[:cached].nil? && !ignore_query?(sql)
@@ -287,6 +294,7 @@ module Prosopite
287
294
 
288
295
  tc[:prosopite_query_counter][location_key] += 1
289
296
  tc[:prosopite_query_holder][location_key] << sql
297
+ tc[:prosopite_query_duration][location_key] += (finish - start) * 1000 if tc[:prosopite_query_duration]
290
298
 
291
299
  if tc[:prosopite_query_counter][location_key] > 1
292
300
  tc[:prosopite_query_caller][location_key] = query_caller
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: 2.1.2
4
+ version: 2.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: 2025-09-19 00:00:00.000000000 Z
11
+ date: 2026-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry