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 +4 -4
- data/config/initializers/n_plus_one_detection.rb +1 -1
- data/lib/active_record/query_counter.rb +1 -1
- data/lib/cookpad/performance/engine.rb +4 -2
- data/lib/cookpad/performance/n_plus_one_detection.rb +25 -0
- data/lib/cookpad/performance/railtie.rb +16 -0
- data/lib/cookpad/performance/version.rb +1 -1
- data/lib/cookpad/performance.rb +1 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a404a545801a9cd8708cf2e6cea28697d886b4102fa99fbd59d6a3e0f3f0498
|
4
|
+
data.tar.gz: 5b67a526c158ec16eace9a14f646e78bc0155d6a016b7d86f7f0dce5f9b11f83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
@@ -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
|
-
|
10
|
-
|
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
|
data/lib/cookpad/performance.rb
CHANGED
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.
|
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-
|
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.
|
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: []
|