cookpad-performance 0.3.0 → 0.3.3

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: 81a44685e535bbef878f87e3cd2b78aad407f2a6ca99fe0389919b8c116fcff6
4
- data.tar.gz: 4dd6fee0c2ad710e85bfd5079e28143445a683c81d2f3432730deb92eee706d1
3
+ metadata.gz: 2a404a545801a9cd8708cf2e6cea28697d886b4102fa99fbd59d6a3e0f3f0498
4
+ data.tar.gz: 5b67a526c158ec16eace9a14f646e78bc0155d6a016b7d86f7f0dce5f9b11f83
5
5
  SHA512:
6
- metadata.gz: e704c4aa1ff14ce297b86e0e72bf06f054eeedc40d7ba5e2d0756ff626caf9d6bc6fd37b7ebdc345870db46e2b2a15a5b34eef8451ef855a2b42d848906df6de
7
- data.tar.gz: 400b71733f944ae054f9634905dfe925c42d061a5d9b373f479c42b22bea884f6d541e5118b950b256011fda5655d4d84a0dabe595b95e582c22fdb9919fe84b
6
+ metadata.gz: 5e638ac0ed6546d07b77c7655a6ce81756597cef53e93766f217893b847c918e8605b883cbb96b7bc24bf180584d058273ea5f1a57a59911fde6749f9e53e1dd
7
+ data.tar.gz: baef32dafa0628231d0842f6f8173db4b9808d16e5d6cc585efff3fc914f8335c5f76ef6f4b1f09e05a95fc647ac4829cab4e056b0e6dfcc4a329ea372ba8c90
@@ -1,5 +1,5 @@
1
1
  if (ENV["LOG_N_PLUS_ONE_QUERIES"] == "true" || ENV["RAISE_N_PLUS_ONE_QUERIES"] == "true") &&
2
- (Rails.env.development? || Rails.env.test?)
2
+ (Rails.env.development? || Rails.env.test?)
3
3
  require "prosopite"
4
4
  Prosopite.rails_logger = ENV["LOG_N_PLUS_ONE_QUERIES"] == "true"
5
5
  Prosopite.prosopite_logger = true
@@ -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
@@ -0,0 +1,16 @@
1
+ module Cookpad
2
+ module Performance
3
+ class Railtie < ::Rails::Railtie
4
+ DEFAULTS_IVAR_NAME = "@defaults".freeze
5
+ private_constant :DEFAULTS_IVAR_NAME
6
+
7
+ config.after_initialize do
8
+ if ENV["PROFILE"] && Rails.env.development? && defined?(Webpacker)
9
+ default_config = Webpacker.config.instance_variable_get(DEFAULTS_IVAR_NAME)
10
+ default_config["compile"] = false
11
+ Webpacker.config.instance_variable_set(DEFAULTS_IVAR_NAME, default_config)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module Cookpad
2
2
  module Performance
3
- VERSION = "0.3.0".freeze
3
+ VERSION = "0.3.3".freeze
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  require "rails"
2
2
  require "cookpad/performance/version"
3
3
  require "cookpad/performance/engine"
4
+ require "cookpad/performance/railtie" if defined?(Rails::Railtie)
4
5
 
5
6
  module Cookpad
6
7
  module Performance
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.0
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cookpad Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-10 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prosopite
@@ -225,6 +225,8 @@ 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
229
+ - lib/cookpad/performance/railtie.rb
228
230
  - lib/cookpad/performance/version.rb
229
231
  homepage: https://github.com/cookpad/cookpad-performance
230
232
  licenses:
@@ -234,7 +236,7 @@ metadata:
234
236
  source_code_uri: https://github.com/cookpad/cookpad-performance
235
237
  changelog_uri: https://github.com/cookpad/cookpad-performance/blob/main/CHANGELOG
236
238
  rubygems_mfa_required: 'true'
237
- post_install_message:
239
+ post_install_message:
238
240
  rdoc_options: []
239
241
  require_paths:
240
242
  - lib
@@ -249,8 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
251
  - !ruby/object:Gem::Version
250
252
  version: '0'
251
253
  requirements: []
252
- rubygems_version: 3.3.8
253
- signing_key:
254
+ rubygems_version: 3.3.7
255
+ signing_key:
254
256
  specification_version: 4
255
257
  summary: Rails app performance tools
256
258
  test_files: []