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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 365c0473adb5bf4852a8d3aba676ead327a1f247797e53426ce2aea1f16a38eb
4
- data.tar.gz: ed71d98428553125c14593ee0c903d3263aeeca4a12061fef2d8ff7502d7aac5
3
+ metadata.gz: 65e21efd9a10f7a591f13ebdb9897ffd0b8a398cab63d70c62eb7c216441abd1
4
+ data.tar.gz: 911bd0254c08ba13ea4d54c14bba0985509093e66900176ef0db724a1b341255
5
5
  SHA512:
6
- metadata.gz: 1dff1f487085b1e75d80a571c5c0e16751f7338465ef6b056ad3a4a7b88a9c09466d356e91389e2d99d94dfb6434b8852f2a3456f5b16501680720c99b728920
7
- data.tar.gz: 4e4aa015ae8c67096f29b0fba860fb76507709d2a99e6496441f531db3d811393e38cefeb6187bd9858ee98c6454d8befa213e3c91594858e96a45acb0edc609
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
- if ActiveRecord::VERSION::MAJOR >= 5
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
- if ActiveRecord::VERSION::MAJOR >= 7
71
- def preload(association_name)
72
- rs = records_with_association(association_name).reject { |r| r.association(association_name).loaded? }
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)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PredictiveLoad
4
+ VERSION = "0.10.0"
5
+ end
@@ -27,8 +27,4 @@ module PredictiveLoad
27
27
  end
28
28
  end
29
29
 
30
- if ActiveRecord::VERSION::MAJOR >= 5
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.9.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: 2024-07-02 00:00:00.000000000 Z
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: '6.0'
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: '6.0'
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: '2.7'
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.11
66
- signing_key:
60
+ rubygems_version: 3.5.22
61
+ signing_key:
67
62
  specification_version: 4
68
63
  summary: ''
69
64
  test_files: []