cookpad-performance 0.3.1 → 0.3.2

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: e6178b382d73886acf8368666545f31864a5fc558606c660f4a3b37f291358d5
4
- data.tar.gz: 47e6595496257a8e39d97224b471622afdaf977eedd2adf423bfbb502b5bf74b
3
+ metadata.gz: 8b97d8b51a198e5add75ab5630f44ae7390f5d62c9755bb122c036cbf3b95038
4
+ data.tar.gz: 42626001db703524d4b670de264f116c5074b6a30760714bf943775f95491574
5
5
  SHA512:
6
- metadata.gz: 7ec0eca928c77113427864e46e8cd37fcf807efa4197ac526f3cb4bd36f240cdd49a9c9d0bfb0c3e5e40a4e4ae8eefddaa737afb118767bc255eca31e3a694a8
7
- data.tar.gz: 8f153c05892b5cf1bf6581d5078a824819ce07d18bce66e724a970e251a25a90d0e3b52638bf05d2c29b181336e81521e4f931453681443c14df84aaa4892fc1
6
+ metadata.gz: 38f3c931186e7046ece11c6abe8d82cccaa9174b6623cffe60b4e0a47541c154b4f964ec6eb247928b4b52f1c7472cd963581eff3fbffabbf31e61b897e4e342
7
+ data.tar.gz: 3ac2eac28f69e017e2907c709ad660cbd55889d2268432e11508edab76141ce6183af1105546aa9d3649758b378d82f15e76c2b392a365d74aed354f0abc74a8
@@ -50,7 +50,7 @@ module ActiveRecord
50
50
  end
51
51
 
52
52
  private
53
-
53
+
54
54
  def counter
55
55
  @_counter ||= Hash.new { |hash, key| hash[key] = 0 }
56
56
  end
@@ -6,7 +6,8 @@ module Cookpad
6
6
  config.to_prepare do
7
7
  if !Rails.env.production? &&
8
8
  (ENV["LOG_N_PLUS_ONE_QUERIES"] == "true" ||
9
- ENV["RAISE_N_PLUS_ONE_QUERIES"] == "true")
9
+ ENV["RAISE_N_PLUS_ONE_QUERIES"] == "true")
10
+ require "cookpad/performance/n_plus_one_detection"
10
11
 
11
12
  ActionController::Base.include(Cookpad::Performance::NPlusOneDetection)
12
13
  end
@@ -0,0 +1,25 @@
1
+ module Cookpad
2
+ module Performance
3
+ module NPlusOneDetection
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ around_action :n_plus_one_detection, if: :should_detect_n_plus_ones?
8
+ end
9
+
10
+ private
11
+
12
+ def should_detect_n_plus_ones?
13
+ ENV["LOG_N_PLUS_ONE_QUERIES"] == "true" ||
14
+ ENV["RAISE_N_PLUS_ONE_QUERIES"] == "true"
15
+ end
16
+
17
+ def n_plus_one_detection
18
+ Prosopite.scan
19
+ yield
20
+ ensure
21
+ Prosopite.finish
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Cookpad
2
2
  module Performance
3
- VERSION = "0.3.1".freeze
3
+ VERSION = "0.3.2".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookpad-performance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cookpad Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-10 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prosopite
@@ -225,6 +225,7 @@ files:
225
225
  - lib/cookpad/performance.rb
226
226
  - lib/cookpad/performance/disable_cached_query_logging.rb
227
227
  - lib/cookpad/performance/engine.rb
228
+ - lib/cookpad/performance/n_plus_one_detection.rb
228
229
  - lib/cookpad/performance/version.rb
229
230
  homepage: https://github.com/cookpad/cookpad-performance
230
231
  licenses: