jit_preloader 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -0
- data/.gitignore +1 -0
- data/jit_preloader.gemspec +4 -1
- data/lib/jit_preloader/active_record/base.rb +2 -0
- data/lib/jit_preloader/version.rb +1 -1
- data/spec/lib/jit_preloader/active_record/base_spec.rb +22 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dac1fcb3b291d3064e2f06455c08d0b25d7c4875bb4f7c5938c194c6ca9dc232
|
4
|
+
data.tar.gz: 5704f5b84dfd9b99898bf145622cd3175afbbf5a4cee3ecb2a4599d7a7e5fbc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b603e9e2fc4748b8765b8329ac435a17cdf5753b9a69479c44fdd78f3398293e1ffccd666667bf93a83db15dc326fa9d389a06bc930d00998032111c2dcea4
|
7
|
+
data.tar.gz: 88c93ec8fb2ad3e24b2209ed4c456389b0f93c0b8b729f60ccccd5f00e7960cb12251f4cfaf364d0f718cfe788803cc2dbd55799ae61832d2ee3f07d6291fe50
|
data/.github/workflows/ci.yml
CHANGED
data/.gitignore
CHANGED
data/jit_preloader.gemspec
CHANGED
@@ -10,7 +10,10 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["kyle.doliveira@clio.com"]
|
11
11
|
spec.summary = %q{Tool to understand N+1 queries and to remove them}
|
12
12
|
spec.description = %q{The JitPreloader has the ability to send notifications when N+1 queries occur to help guage how problematic they are for your code base and a way to remove all of the commons explicitly or automatically}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/clio/jit_preloader"
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
16
|
+
|
14
17
|
spec.license = "MIT"
|
15
18
|
|
16
19
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -22,6 +22,7 @@ module JitPreloadExtension
|
|
22
22
|
def preload_scoped_relation(name:, base_association:, preload_scope: nil)
|
23
23
|
return jit_preload_scoped_relations[name] if jit_preload_scoped_relations&.key?(name)
|
24
24
|
|
25
|
+
base_association = base_association.to_sym
|
25
26
|
records = jit_preloader&.records || [self]
|
26
27
|
previous_association_values = {}
|
27
28
|
|
@@ -55,6 +56,7 @@ module JitPreloadExtension
|
|
55
56
|
def preload_scoped_relation(name:, base_association:, preload_scope: nil)
|
56
57
|
return jit_preload_scoped_relations[name] if jit_preload_scoped_relations&.key?(name)
|
57
58
|
|
59
|
+
base_association = base_association.to_sym
|
58
60
|
records = jit_preloader&.records || [self]
|
59
61
|
previous_association_values = {}
|
60
62
|
|
@@ -106,5 +106,27 @@ RSpec.describe "ActiveRecord::Base Extensions" do
|
|
106
106
|
expect(value).to eq([])
|
107
107
|
end
|
108
108
|
end
|
109
|
+
|
110
|
+
context "when preload_scoped_relation with string base_association name" do
|
111
|
+
it "preload properly" do
|
112
|
+
contacts = Contact.jit_preload.limit(2).to_a
|
113
|
+
|
114
|
+
call_with_string = lambda { |contact| contact.preload_scoped_relation(
|
115
|
+
name: "American Addresses",
|
116
|
+
base_association: "addresses",
|
117
|
+
preload_scope: Address.where(country: usa)
|
118
|
+
) }
|
119
|
+
|
120
|
+
usa_addresses = contacts.first.addresses.where(country: usa).to_a
|
121
|
+
expect do
|
122
|
+
expect(call_with_string.call(contacts.first)).to match_array usa_addresses
|
123
|
+
end.to make_database_queries(count: 1)
|
124
|
+
|
125
|
+
usa_addresses = contacts.last.addresses.where(country: usa).to_a
|
126
|
+
expect do
|
127
|
+
expect(call_with_string.call(contacts.last)).to match_array usa_addresses
|
128
|
+
end.to_not make_database_queries
|
129
|
+
end
|
130
|
+
end
|
109
131
|
end
|
110
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jit_preloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle d'Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -176,10 +176,12 @@ files:
|
|
176
176
|
- spec/spec_helper.rb
|
177
177
|
- spec/support/database.rb
|
178
178
|
- spec/support/models.rb
|
179
|
-
homepage:
|
179
|
+
homepage: https://github.com/clio/jit_preloader
|
180
180
|
licenses:
|
181
181
|
- MIT
|
182
|
-
metadata:
|
182
|
+
metadata:
|
183
|
+
homepage_uri: https://github.com/clio/jit_preloader
|
184
|
+
source_code_uri: https://github.com/clio/jit_preloader
|
183
185
|
post_install_message:
|
184
186
|
rdoc_options: []
|
185
187
|
require_paths:
|