predictive_load 0.9.0 → 0.10.0
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/README.md +18 -0
- data/lib/predictive_load/active_record_collection_observation.rb +1 -17
- data/lib/predictive_load/loader.rb +3 -10
- data/lib/predictive_load/version.rb +5 -0
- data/lib/predictive_load.rb +1 -5
- metadata +10 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65e21efd9a10f7a591f13ebdb9897ffd0b8a398cab63d70c62eb7c216441abd1
|
4
|
+
data.tar.gz: 911bd0254c08ba13ea4d54c14bba0985509093e66900176ef0db724a1b341255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7df026e12279d049deb22a457626c939273da4884bf1bd40eb4b21c4d0e32c008d170f16823d58b063b1652adaa73f1b636c0ddde5a42bbd3e49ffe87d19834f
|
7
|
+
data.tar.gz: 44709e9159871d049ae8b565a9c5369e909edb5c17de28f70317d216c93826e680533b2b3936e8168067804f580734bb114757cb950a467499b229b36e8361e7
|
data/README.md
CHANGED
@@ -67,3 +67,21 @@ end
|
|
67
67
|
|
68
68
|
* Calling association#size will trigger an N+1 on SELECT COUNT(*). Work around by calling #length, loading all records.
|
69
69
|
* Calling first / last will trigger an N+1.
|
70
|
+
|
71
|
+
### Releasing a new version
|
72
|
+
|
73
|
+
A new version is published to RubyGems.org every time a change to `version.rb` is pushed to the `main` branch.
|
74
|
+
|
75
|
+
In short, follow these steps:
|
76
|
+
1. Update `version.rb`,
|
77
|
+
2. update version in all `Gemfile.lock` files,
|
78
|
+
3. merge this change into `main`, and
|
79
|
+
4. look at [the action](https://github.com/zendesk/predictive_load/actions/workflows/publish.yml) for output.
|
80
|
+
|
81
|
+
To create a pre-release from a non-main branch:
|
82
|
+
1. change the version in `version.rb` to something like `1.2.0.pre.1` or `2.0.0.beta.2`,
|
83
|
+
2. push this change to your branch,
|
84
|
+
3. go to [Actions → “Publish to RubyGems.org” on GitHub](https://github.com/zendesk/predictive_load/actions/workflows/publish.yml),
|
85
|
+
4. click the “Run workflow” button,
|
86
|
+
5. pick your branch from a dropdown.
|
87
|
+
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module PredictiveLoad::ActiveRecordCollectionObservation
|
2
2
|
def self.included(base)
|
3
3
|
ActiveRecord::Relation.class_attribute :collection_observer
|
4
|
-
|
5
|
-
ActiveRecord::Relation.prepend Rails5RelationObservation
|
6
|
-
else
|
7
|
-
ActiveRecord::Relation.prepend Rails4RelationObservation
|
8
|
-
end
|
4
|
+
ActiveRecord::Relation.prepend Rails5RelationObservation
|
9
5
|
ActiveRecord::Base.include CollectionMember
|
10
6
|
ActiveRecord::Base.extend UnscopedTracker
|
11
7
|
ActiveRecord::Associations::Association.prepend AssociationNotification
|
@@ -24,18 +20,6 @@ module PredictiveLoad::ActiveRecordCollectionObservation
|
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
27
|
-
module Rails4RelationObservation
|
28
|
-
# this essentially intercepts the enumerable methods that would result in n+1s since most of
|
29
|
-
# those are delegated to :to_a in Rails 5+ in the ActiveRecord::Relation::Delegation module
|
30
|
-
def to_a
|
31
|
-
record_array = super
|
32
|
-
if record_array.size > 1 && collection_observer
|
33
|
-
collection_observer.observe(record_array.dup)
|
34
|
-
end
|
35
|
-
record_array
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
23
|
module CollectionMember
|
40
24
|
attr_accessor :collection_observer
|
41
25
|
end
|
@@ -67,16 +67,9 @@ module PredictiveLoad
|
|
67
67
|
# any preloading.
|
68
68
|
#
|
69
69
|
# Fix is pretty simple, ignore any record with association already loaded.
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
ActiveRecord::Associations::Preloader.new(records: rs, associations: [association_name]).call
|
74
|
-
end
|
75
|
-
else
|
76
|
-
def preload(association_name)
|
77
|
-
rs = records_with_association(association_name).reject { |r| r.association(association_name).loaded? }
|
78
|
-
ActiveRecord::Associations::Preloader.new.preload(rs, [association_name])
|
79
|
-
end
|
70
|
+
def preload(association_name)
|
71
|
+
rs = records_with_association(association_name).reject { |r| r.association(association_name).loaded? }
|
72
|
+
ActiveRecord::Associations::Preloader.new(records: rs, associations: [association_name]).call
|
80
73
|
end
|
81
74
|
|
82
75
|
def records_with_association(association_name)
|
data/lib/predictive_load.rb
CHANGED
@@ -27,8 +27,4 @@ module PredictiveLoad
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
ActiveRecord::Associations::Builder::Association.singleton_class.prepend(PredictiveLoad::Rails5AssociationOptions)
|
32
|
-
else
|
33
|
-
ActiveRecord::Associations::Builder::Association.valid_options << :predictive_load
|
34
|
-
end
|
30
|
+
ActiveRecord::Associations::Builder::Association.singleton_class.prepend(PredictiveLoad::Rails5AssociationOptions)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: predictive_load
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Chapweske
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,20 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '7.2'
|
19
|
+
version: '7.1'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '7.2'
|
26
|
+
version: '7.1'
|
33
27
|
description: Predictive loader
|
34
28
|
email:
|
35
29
|
- eac@zendesk.com
|
@@ -43,11 +37,12 @@ files:
|
|
43
37
|
- lib/predictive_load/active_record_collection_observation.rb
|
44
38
|
- lib/predictive_load/loader.rb
|
45
39
|
- lib/predictive_load/preload_log.rb
|
40
|
+
- lib/predictive_load/version.rb
|
46
41
|
homepage: https://github.com/zendesk/predictive_load
|
47
42
|
licenses:
|
48
43
|
- Apache License Version 2.0
|
49
44
|
metadata: {}
|
50
|
-
post_install_message:
|
45
|
+
post_install_message:
|
51
46
|
rdoc_options: []
|
52
47
|
require_paths:
|
53
48
|
- lib
|
@@ -55,15 +50,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
50
|
requirements:
|
56
51
|
- - ">="
|
57
52
|
- !ruby/object:Gem::Version
|
58
|
-
version: '
|
53
|
+
version: '3.3'
|
59
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
55
|
requirements:
|
61
56
|
- - ">="
|
62
57
|
- !ruby/object:Gem::Version
|
63
58
|
version: '0'
|
64
59
|
requirements: []
|
65
|
-
rubygems_version: 3.5.
|
66
|
-
signing_key:
|
60
|
+
rubygems_version: 3.5.22
|
61
|
+
signing_key:
|
67
62
|
specification_version: 4
|
68
63
|
summary: ''
|
69
64
|
test_files: []
|