cookpad-performance 0.2.1 → 0.3.2

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: 16ed8a79cc750fdc941bd559af36feda7bff7b54a6deaf36729fc277cf829a37
4
- data.tar.gz: 4c004dc7a7965b55802b4011d66477aed68a9a0d5528e227a43684b9170f18f3
3
+ metadata.gz: 8b97d8b51a198e5add75ab5630f44ae7390f5d62c9755bb122c036cbf3b95038
4
+ data.tar.gz: 42626001db703524d4b670de264f116c5074b6a30760714bf943775f95491574
5
5
  SHA512:
6
- metadata.gz: f73325fca388869a266b077f27c7c111309346da0d7e09221e64e7385ad7290b31f9c55fd0d619a0a5c067868afa76c40e07fb9d8b14f1bb3d88cf91fa8c5cc6
7
- data.tar.gz: 8292570b2d24a37cd489a0f06b718436ac61dbb0d811ca0e4686f3182c93db84ff68848cac6e2934cdda324e40f0a37875a1652e3cfcfac659230b6dc0f72411
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,8 +6,10 @@ 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")
10
- ActionController::Base.include(NPlusOneDetection)
9
+ ENV["RAISE_N_PLUS_ONE_QUERIES"] == "true")
10
+ require "cookpad/performance/n_plus_one_detection"
11
+
12
+ ActionController::Base.include(Cookpad::Performance::NPlusOneDetection)
11
13
  end
12
14
  end
13
15
  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.2.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.2.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
- - Bodacious
7
+ - Cookpad Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-29 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
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '7.0'
33
+ version: '6.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '7.0'
40
+ version: '6.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ dependencies:
208
208
  version: '4.2'
209
209
  description: Provides a set of performance tools for our Rails apps
210
210
  email:
211
- - gavin@gavinmorrice.com
211
+ - kaihatsu@cookpad.com
212
212
  executables: []
213
213
  extensions: []
214
214
  extra_rdoc_files: []
@@ -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: