n1_loader 1.6.0 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d914dd09225515a579945ab616916bf1ad446101c5051c4cf1b72c46d38c107
4
- data.tar.gz: a304c32e35294c5646fafe5c65a5de6c637e80e080d80ac16f957d77a3ebe4c6
3
+ metadata.gz: b8a914cabc2c837109b3f6f72b78dbbc4b6e64b87049568e9c6733f29b2a6867
4
+ data.tar.gz: ce9b88ee6121de3540dd13789da0c28b8c01e32598ed1dacb10af16da05e82b9
5
5
  SHA512:
6
- metadata.gz: 738d8ca021bca48a41486689c74506af32dc2bca8a542398272edaa72aa57dd49247249d04afe8d9b834cc28cd9b725f0a9b1d8d7f5dd80176cfd3c9ca711f08
7
- data.tar.gz: c73ddc81593e0cbd0450457143726b9d57fbce0a27c09ede70ea3f269816b7ae7374e5dc1c06dda4e8b0ee8c21a0c96248ed4afb9e3d7f26ec5b5ac46e038d16
6
+ metadata.gz: 1a290cee96e8ba97c181267efde4f94ca494037d05e4cce93e58131faa4f6cc22c072a792e24631479b41a62cdfff0857e3dd3f51252cf7d05a4f3252eb41c5b
7
+ data.tar.gz: b4fcf0e7f3911441d542b6ab5d9f657671dcbf7864822f11c2e6854d957e49787026490f4595323c14d60348259eef5a522da4312fe6ee8ccd78a092437d8346
@@ -1,10 +1,12 @@
1
1
  name: Rubocop
2
2
 
3
3
  on:
4
- - pull_request
4
+ pull_request:
5
+ schedule:
6
+ - cron: '0 0 * * 0'
5
7
 
6
8
  jobs:
7
- tests:
9
+ rubocop:
8
10
  runs-on: ubuntu-latest
9
11
 
10
12
  steps:
@@ -1,7 +1,9 @@
1
1
  name: RSpec tests
2
2
 
3
3
  on:
4
- - pull_request
4
+ pull_request:
5
+ schedule:
6
+ - cron: '0 0 * * 0'
5
7
 
6
8
  jobs:
7
9
  tests:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.6.2] - 2022/11/23
2
+
3
+ - Add fund metadata
4
+
5
+ ## [1.6.1] - 2022/10/29
6
+
7
+ - Fix ArLazyPreload context setup when using isolated loaders for objects without the context.
8
+
1
9
  ## [1.6.0] - 2022/10/24
2
10
 
3
11
  - Add support of ArLazyPreload context for isolated loaders.
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # N1Loader
2
2
 
3
- [![CircleCI][1]][2]
4
3
  [![Gem Version][3]][4]
4
+ [![][11]][12]
5
+ [![][13]][14]
5
6
  [![][9]][10]
6
7
 
7
8
  N1Loader is designed to provide a simple way for avoiding [N+1 issues][7] of any kind.
@@ -11,7 +12,8 @@ For example, it can help with resolving N+1 for:
11
12
  - complex calculations
12
13
  - and many more
13
14
 
14
- > [Toptal](https://www.toptal.com#snag-only-shrewd-web-development-experts) is hiring! [Join](https://www.toptal.com#snag-only-shrewd-web-development-experts) as Freelancer or [write me](mailto:lawliet.djez@gmail.com) if you want to join Core team.
15
+ > If the project helps you or your organization, I would be very grateful if you [contribute][15] or [donate][10].
16
+ > Your support is an incredible motivation and the biggest reward for my hard work.
15
17
 
16
18
  ___Support:___ ActiveRecord 5, 6, and 7.
17
19
 
@@ -253,8 +255,6 @@ Everyone interacting in the N1Loader project's codebases, issue trackers, chat r
253
255
 
254
256
  Copyright (c) Evgeniy Demin. See [LICENSE.txt](LICENSE.txt) for further details.
255
257
 
256
- [1]: https://circleci.com/gh/djezzzl/n1_loader/tree/master.svg?style=shield
257
- [2]: https://circleci.com/gh/djezzzl/n1_loader/tree/master
258
258
  [3]: https://badge.fury.io/rb/n1_loader.svg
259
259
  [4]: https://badge.fury.io/rb/n1_loader
260
260
  [5]: https://github.com/rails/rails/tree/main/activerecord
@@ -263,3 +263,8 @@ Copyright (c) Evgeniy Demin. See [LICENSE.txt](LICENSE.txt) for further details.
263
263
  [8]: https://github.com/djezzzl/n1_loader
264
264
  [9]: https://opencollective.com/n1_loader/tiers/badge.svg
265
265
  [10]: https://opencollective.com/n1_loader#support
266
+ [11]: https://github.com/djezzzl/n1_loader/actions/workflows/tests.yml/badge.svg?branch=master
267
+ [12]: https://github.com/djezzzl/n1_loader/actions/workflows/tests.yml?query=event%3Aschedule
268
+ [13]: https://github.com/djezzzl/n1_loader/actions/workflows/rubocop.yml/badge.svg?branch=master
269
+ [14]: https://github.com/djezzzl/n1_loader/actions/workflows/rubocop.yml?query=event%3Aschedule
270
+ [15]: https://github.com/djezzzl/n1_loader#contributing
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Raised when a single object without ArLazyPreload context was passed to an isolated loader.
4
- N1Loader::Loader::MissingArLazyPreloadContext = Class.new(StandardError)
3
+ # Raised when a single object without ArLazyPreload context support was passed to an isolated loader.
4
+ N1Loader::Loader::UnsupportedArLazyPreload = Class.new(StandardError)
5
5
 
6
6
  # Defines a singleton method method that allows isolated loaders
7
7
  # to use ArLazyPreload context without passing sibling records.
8
8
  N1Loader::Loader.define_singleton_method(:for) do |element, **args|
9
- # It is required to have an ArLazyPreload context defined
10
- if !element.respond_to?(:lazy_preload_context) || element.lazy_preload_context.nil?
11
- raise N1Loader::Loader::MissingArLazyPreloadContext
9
+ # It is required to have an ArLazyPreload context supported
10
+ raise N1Loader::Loader::UnsupportedArLazyPreload unless element.respond_to?(:lazy_preload_context)
11
+
12
+ if element.lazy_preload_context.nil?
13
+ ArLazyPreload::Context.register(
14
+ records: [element],
15
+ association_tree: [],
16
+ auto_preload: true
17
+ )
12
18
  end
13
19
 
14
20
  # Fetch or initialize loader from ArLazyPreload context
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module N1Loader
4
- VERSION = "1.6.0"
4
+ VERSION = "1.6.2"
5
5
  end
data/n1_loader.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = "https://github.com/djezzzl/n1_loader"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/djezzzl/n1_loader/master/CHANGELOG.md"
19
+ spec.metadata["funding_uri"] = "https://opencollective.com/n1_loader#support"
19
20
 
20
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: n1_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-24 00:00:00.000000000 Z
11
+ date: 2022-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -143,7 +143,6 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - ".circleci/config.yml"
147
146
  - ".github/workflows/rubocop.yml"
148
147
  - ".github/workflows/tests.yml"
149
148
  - ".gitignore"
@@ -207,6 +206,7 @@ metadata:
207
206
  homepage_uri: https://github.com/djezzzl/n1_loader
208
207
  source_code_uri: https://github.com/djezzzl/n1_loader
209
208
  changelog_uri: https://github.com/djezzzl/n1_loader/master/CHANGELOG.md
209
+ funding_uri: https://opencollective.com/n1_loader#support
210
210
  post_install_message:
211
211
  rdoc_options: []
212
212
  require_paths:
data/.circleci/config.yml DELETED
@@ -1,152 +0,0 @@
1
- version: 2.1
2
-
3
- executors:
4
- ruby:
5
- description: The official CircleCI Ruby Docker image
6
- parameters:
7
- tag:
8
- description: The circleci/ruby Docker image version tag
9
- type: string
10
- default: latest
11
- docker:
12
- - image: circleci/ruby:<< parameters.tag >>
13
- environment:
14
- BUNDLE_JOBS: 4
15
- BUNDLE_RETRY: 3
16
- working_directory: ~/n1_loader
17
-
18
- jobs:
19
- checkout:
20
- executor: ruby
21
- steps:
22
- - checkout
23
- - persist_to_workspace:
24
- root: ~/n1_loader
25
- paths:
26
- - .
27
-
28
- build:
29
- parameters:
30
- ruby-version:
31
- type: string
32
- activerecord-gemfile:
33
- type: string
34
- ar_lazy_preload-gemfile:
35
- type: string
36
- environment:
37
- ACTIVERECORD_GEMFILE: << parameters.activerecord-gemfile >>
38
- AR_LAZY_PRELOAD_GEMFILE: << parameters.ar_lazy_preload-gemfile >>
39
- executor:
40
- name: ruby
41
- tag: << parameters.ruby-version >>
42
- steps:
43
- - attach_workspace:
44
- at: ~/n1_loader
45
- - run:
46
- name: Install the gems specified by the Gemfile
47
- command: bundle install
48
- - run:
49
- name: Run Core RSpec
50
- command: |
51
- bundle exec rspec --profile 10 \
52
- --format RspecJunitFormatter \
53
- --out test_results/core.xml \
54
- --format progress \
55
- spec/n1_loader_spec.rb
56
- - run:
57
- name: Run ActiveRecord integration RSpec
58
- command: |
59
- bundle exec rspec --profile 10 \
60
- --format RspecJunitFormatter \
61
- --out test_results/activerecord-integration.xml \
62
- --format progress \
63
- spec/n1_loader_spec.rb \
64
- spec/activerecord_spec.rb
65
- - run:
66
- name: Run ActiveRecord integration RSpec
67
- command: |
68
- bundle exec rspec --profile 10 \
69
- --format RspecJunitFormatter \
70
- --out test_results/ar-lazy-preload-integration.xml \
71
- --format progress \
72
- spec/n1_loader_spec.rb \
73
- spec/activerecord_spec.rb \
74
- spec/ar_lazy_preload_spec.rb
75
- - store_test_results:
76
- path: test_results
77
-
78
- rubocop:
79
- executor:
80
- name: ruby
81
- tag: "2.5"
82
- steps:
83
- - attach_workspace:
84
- at: ~/n1_loader
85
- - run:
86
- name: Install the gems specified by the Gemfile
87
- command: bundle install
88
- - run:
89
- name: Lint Ruby code with RuboCop
90
- command: bundle exec rubocop --parallel
91
-
92
- workflows:
93
- version: 2
94
- default: &default
95
- jobs:
96
- - checkout
97
- - build:
98
- requires:
99
- - checkout
100
- matrix:
101
- parameters:
102
- ruby-version: [
103
- "2.7",
104
- "latest"
105
- ]
106
- activerecord-gemfile: [
107
- "ar_5_latest",
108
- "ar_6_latest",
109
- "ar_7_latest"
110
- ]
111
- ar_lazy_preload-gemfile: [
112
- "ar_lazy_preload_0.6.1",
113
- "ar_lazy_preload_master"
114
- ]
115
- exclude:
116
- # AR 5 and ruby 3+
117
- - ruby-version: "latest"
118
- activerecord-gemfile: "ar_5_latest"
119
- ar_lazy_preload-gemfile: "ar_lazy_preload_0.6.1"
120
-
121
- - ruby-version: "latest"
122
- activerecord-gemfile: "ar_5_latest"
123
- ar_lazy_preload-gemfile: "ar_lazy_preload_master"
124
-
125
- # AR 7 and ar_lazy_preload < 1
126
- - ruby-version: "2.5"
127
- activerecord-gemfile: "ar_7_latest"
128
- ar_lazy_preload-gemfile: "ar_lazy_preload_0.6.1"
129
-
130
- - ruby-version: "2.7"
131
- activerecord-gemfile: "ar_7_latest"
132
- ar_lazy_preload-gemfile: "ar_lazy_preload_0.6.1"
133
-
134
- - ruby-version: "latest"
135
- activerecord-gemfile: "ar_7_latest"
136
- ar_lazy_preload-gemfile: "ar_lazy_preload_0.6.1"
137
-
138
-
139
- name: ruby-<< matrix.ruby-version >>-<< matrix.activerecord-gemfile >>-<< matrix.ar_lazy_preload-gemfile >>
140
- - rubocop:
141
- requires:
142
- - checkout
143
-
144
- nightly:
145
- triggers:
146
- - schedule:
147
- cron: "0 0 * * *"
148
- filters:
149
- branches:
150
- only:
151
- - master
152
- <<: *default