chewy 6.0.0 → 7.6.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/.github/CODEOWNERS +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +16 -0
- data/.github/dependabot.yml +42 -0
- data/.github/workflows/ruby.yml +60 -0
- data/.rubocop.yml +16 -8
- data/.rubocop_todo.yml +110 -22
- data/CHANGELOG.md +396 -105
- data/CODE_OF_CONDUCT.md +14 -0
- data/CONTRIBUTING.md +63 -0
- data/Gemfile +4 -10
- data/Guardfile +3 -1
- data/README.md +497 -275
- data/chewy.gemspec +5 -20
- data/gemfiles/base.gemfile +12 -0
- data/gemfiles/rails.6.1.activerecord.gemfile +10 -15
- data/gemfiles/rails.7.0.activerecord.gemfile +14 -0
- data/gemfiles/rails.7.1.activerecord.gemfile +14 -0
- data/lib/chewy/config.rb +60 -52
- data/lib/chewy/elastic_client.rb +31 -0
- data/lib/chewy/errors.rb +7 -10
- data/lib/chewy/fields/base.rb +79 -13
- data/lib/chewy/fields/root.rb +4 -14
- data/lib/chewy/index/actions.rb +54 -37
- data/lib/chewy/{type → index}/adapter/active_record.rb +30 -6
- data/lib/chewy/{type → index}/adapter/base.rb +2 -3
- data/lib/chewy/{type → index}/adapter/object.rb +27 -31
- data/lib/chewy/{type → index}/adapter/orm.rb +17 -18
- data/lib/chewy/index/aliases.rb +14 -5
- data/lib/chewy/index/crutch.rb +40 -0
- data/lib/chewy/index/import/bulk_builder.rb +311 -0
- data/lib/chewy/{type → index}/import/bulk_request.rb +6 -7
- data/lib/chewy/{type → index}/import/journal_builder.rb +11 -12
- data/lib/chewy/{type → index}/import/routine.rb +18 -17
- data/lib/chewy/{type → index}/import.rb +76 -32
- data/lib/chewy/{type → index}/mapping.rb +29 -34
- data/lib/chewy/index/observe/active_record_methods.rb +87 -0
- data/lib/chewy/index/observe/callback.rb +34 -0
- data/lib/chewy/index/observe.rb +17 -0
- data/lib/chewy/index/specification.rb +1 -0
- data/lib/chewy/{type → index}/syncer.rb +59 -59
- data/lib/chewy/{type → index}/witchcraft.rb +11 -7
- data/lib/chewy/{type → index}/wrapper.rb +2 -2
- data/lib/chewy/index.rb +67 -94
- data/lib/chewy/journal.rb +25 -14
- data/lib/chewy/log_subscriber.rb +5 -1
- data/lib/chewy/minitest/helpers.rb +86 -13
- data/lib/chewy/minitest/search_index_receiver.rb +24 -26
- data/lib/chewy/railtie.rb +6 -20
- data/lib/chewy/rake_helper.rb +169 -113
- data/lib/chewy/rspec/build_query.rb +12 -0
- data/lib/chewy/rspec/helpers.rb +55 -0
- data/lib/chewy/rspec/update_index.rb +55 -44
- data/lib/chewy/rspec.rb +2 -0
- data/lib/chewy/runtime/version.rb +1 -1
- data/lib/chewy/runtime.rb +1 -1
- data/lib/chewy/search/loader.rb +19 -41
- data/lib/chewy/search/parameters/collapse.rb +16 -0
- data/lib/chewy/search/parameters/concerns/query_storage.rb +2 -2
- data/lib/chewy/search/parameters/ignore_unavailable.rb +27 -0
- data/lib/chewy/search/parameters/indices.rb +13 -58
- data/lib/chewy/search/parameters/knn.rb +16 -0
- data/lib/chewy/search/parameters/order.rb +6 -19
- data/lib/chewy/search/parameters/source.rb +5 -1
- data/lib/chewy/search/parameters/storage.rb +1 -1
- data/lib/chewy/search/parameters/track_total_hits.rb +16 -0
- data/lib/chewy/search/parameters.rb +6 -4
- data/lib/chewy/search/query_proxy.rb +9 -2
- data/lib/chewy/search/request.rb +169 -134
- data/lib/chewy/search/response.rb +5 -5
- data/lib/chewy/search/scoping.rb +7 -8
- data/lib/chewy/search/scrolling.rb +13 -13
- data/lib/chewy/search.rb +9 -19
- data/lib/chewy/stash.rb +19 -30
- data/lib/chewy/strategy/active_job.rb +1 -1
- data/lib/chewy/strategy/atomic_no_refresh.rb +18 -0
- data/lib/chewy/strategy/base.rb +10 -0
- data/lib/chewy/strategy/delayed_sidekiq/scheduler.rb +168 -0
- data/lib/chewy/strategy/delayed_sidekiq/worker.rb +76 -0
- data/lib/chewy/strategy/delayed_sidekiq.rb +30 -0
- data/lib/chewy/strategy/lazy_sidekiq.rb +64 -0
- data/lib/chewy/strategy/sidekiq.rb +2 -1
- data/lib/chewy/strategy.rb +6 -19
- data/lib/chewy/version.rb +1 -1
- data/lib/chewy.rb +39 -86
- data/lib/generators/chewy/install_generator.rb +1 -1
- data/lib/tasks/chewy.rake +36 -32
- data/migration_guide.md +46 -8
- data/spec/chewy/config_spec.rb +16 -41
- data/spec/chewy/elastic_client_spec.rb +26 -0
- data/spec/chewy/fields/base_spec.rb +432 -147
- data/spec/chewy/fields/root_spec.rb +20 -28
- data/spec/chewy/fields/time_fields_spec.rb +5 -5
- data/spec/chewy/index/actions_spec.rb +368 -59
- data/spec/chewy/{type → index}/adapter/active_record_spec.rb +156 -40
- data/spec/chewy/{type → index}/adapter/object_spec.rb +21 -6
- data/spec/chewy/index/aliases_spec.rb +3 -3
- data/spec/chewy/index/import/bulk_builder_spec.rb +494 -0
- data/spec/chewy/{type → index}/import/bulk_request_spec.rb +5 -12
- data/spec/chewy/{type → index}/import/journal_builder_spec.rb +9 -19
- data/spec/chewy/{type → index}/import/routine_spec.rb +19 -19
- data/spec/chewy/{type → index}/import_spec.rb +164 -98
- data/spec/chewy/index/mapping_spec.rb +135 -0
- data/spec/chewy/index/observe/active_record_methods_spec.rb +68 -0
- data/spec/chewy/index/observe/callback_spec.rb +139 -0
- data/spec/chewy/index/observe_spec.rb +143 -0
- data/spec/chewy/index/settings_spec.rb +3 -1
- data/spec/chewy/index/specification_spec.rb +20 -30
- data/spec/chewy/{type → index}/syncer_spec.rb +14 -19
- data/spec/chewy/{type → index}/witchcraft_spec.rb +20 -22
- data/spec/chewy/index/wrapper_spec.rb +100 -0
- data/spec/chewy/index_spec.rb +60 -105
- data/spec/chewy/journal_spec.rb +25 -74
- data/spec/chewy/minitest/helpers_spec.rb +123 -15
- data/spec/chewy/minitest/search_index_receiver_spec.rb +28 -30
- data/spec/chewy/multi_search_spec.rb +4 -5
- data/spec/chewy/rake_helper_spec.rb +315 -55
- data/spec/chewy/rspec/build_query_spec.rb +34 -0
- data/spec/chewy/rspec/helpers_spec.rb +61 -0
- data/spec/chewy/rspec/update_index_spec.rb +74 -71
- data/spec/chewy/runtime_spec.rb +2 -2
- data/spec/chewy/search/loader_spec.rb +19 -53
- data/spec/chewy/search/pagination/kaminari_examples.rb +4 -6
- data/spec/chewy/search/pagination/kaminari_spec.rb +2 -2
- data/spec/chewy/search/parameters/collapse_spec.rb +5 -0
- data/spec/chewy/search/parameters/ignore_unavailable_spec.rb +67 -0
- data/spec/chewy/search/parameters/indices_spec.rb +26 -117
- data/spec/chewy/search/parameters/knn_spec.rb +5 -0
- data/spec/chewy/search/parameters/order_spec.rb +18 -11
- data/spec/chewy/search/parameters/query_storage_examples.rb +67 -21
- data/spec/chewy/search/parameters/search_after_spec.rb +4 -1
- data/spec/chewy/search/parameters/source_spec.rb +8 -2
- data/spec/chewy/search/parameters/track_total_hits_spec.rb +5 -0
- data/spec/chewy/search/parameters_spec.rb +18 -4
- data/spec/chewy/search/query_proxy_spec.rb +68 -17
- data/spec/chewy/search/request_spec.rb +292 -110
- data/spec/chewy/search/response_spec.rb +12 -12
- data/spec/chewy/search/scrolling_spec.rb +10 -17
- data/spec/chewy/search_spec.rb +40 -34
- data/spec/chewy/stash_spec.rb +9 -21
- data/spec/chewy/strategy/active_job_spec.rb +16 -16
- data/spec/chewy/strategy/atomic_no_refresh_spec.rb +60 -0
- data/spec/chewy/strategy/atomic_spec.rb +9 -10
- data/spec/chewy/strategy/delayed_sidekiq_spec.rb +208 -0
- data/spec/chewy/strategy/lazy_sidekiq_spec.rb +214 -0
- data/spec/chewy/strategy/sidekiq_spec.rb +12 -12
- data/spec/chewy/strategy_spec.rb +19 -15
- data/spec/chewy_spec.rb +24 -107
- data/spec/spec_helper.rb +3 -22
- data/spec/support/active_record.rb +25 -7
- metadata +78 -339
- data/.circleci/config.yml +0 -240
- data/Appraisals +0 -81
- data/gemfiles/rails.5.2.activerecord.gemfile +0 -17
- data/gemfiles/rails.5.2.mongoid.6.4.gemfile +0 -17
- data/gemfiles/rails.6.0.activerecord.gemfile +0 -17
- data/gemfiles/sequel.4.45.gemfile +0 -11
- data/lib/chewy/backports/deep_dup.rb +0 -46
- data/lib/chewy/backports/duplicable.rb +0 -91
- data/lib/chewy/search/pagination/will_paginate.rb +0 -43
- data/lib/chewy/search/parameters/types.rb +0 -20
- data/lib/chewy/strategy/resque.rb +0 -27
- data/lib/chewy/strategy/shoryuken.rb +0 -40
- data/lib/chewy/type/actions.rb +0 -43
- data/lib/chewy/type/adapter/mongoid.rb +0 -67
- data/lib/chewy/type/adapter/sequel.rb +0 -93
- data/lib/chewy/type/crutch.rb +0 -32
- data/lib/chewy/type/import/bulk_builder.rb +0 -122
- data/lib/chewy/type/observe.rb +0 -82
- data/lib/chewy/type.rb +0 -120
- data/lib/sequel/plugins/chewy_observe.rb +0 -63
- data/spec/chewy/search/pagination/will_paginate_examples.rb +0 -63
- data/spec/chewy/search/pagination/will_paginate_spec.rb +0 -23
- data/spec/chewy/search/parameters/types_spec.rb +0 -5
- data/spec/chewy/strategy/resque_spec.rb +0 -46
- data/spec/chewy/strategy/shoryuken_spec.rb +0 -70
- data/spec/chewy/type/actions_spec.rb +0 -50
- data/spec/chewy/type/adapter/mongoid_spec.rb +0 -372
- data/spec/chewy/type/adapter/sequel_spec.rb +0 -472
- data/spec/chewy/type/import/bulk_builder_spec.rb +0 -194
- data/spec/chewy/type/mapping_spec.rb +0 -175
- data/spec/chewy/type/observe_spec.rb +0 -137
- data/spec/chewy/type/wrapper_spec.rb +0 -100
- data/spec/chewy/type_spec.rb +0 -55
- data/spec/support/mongoid.rb +0 -93
- data/spec/support/sequel.rb +0 -80
data/.circleci/config.yml
DELETED
@@ -1,240 +0,0 @@
|
|
1
|
-
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
2
|
-
version: 2.1
|
3
|
-
|
4
|
-
es-env: &es-env
|
5
|
-
cluster.name: elasticsearch
|
6
|
-
transport.host: localhost
|
7
|
-
network.host: 127.0.0.1
|
8
|
-
http.port: 9250
|
9
|
-
discovery.type: single-node
|
10
|
-
xpack.security.enabled: false
|
11
|
-
xpack.monitoring.enabled: false
|
12
|
-
|
13
|
-
workflows:
|
14
|
-
build:
|
15
|
-
jobs:
|
16
|
-
- rubocop
|
17
|
-
- rspec-ruby-26-activerecord61
|
18
|
-
- rspec-ruby-26-activerecord60
|
19
|
-
- rspec-ruby-26-activerecord52
|
20
|
-
- rspec-ruby-26-mongoid
|
21
|
-
- rspec-ruby-27-activerecord61
|
22
|
-
- rspec-ruby-27-activerecord60
|
23
|
-
- rspec-ruby-27-activerecord52
|
24
|
-
- rspec-ruby-27-mongoid
|
25
|
-
- rspec-ruby-30-activerecord61
|
26
|
-
- rspec-ruby-27-activerecord61-es6
|
27
|
-
- rspec-ruby-30-activerecord61-es6
|
28
|
-
|
29
|
-
commands:
|
30
|
-
rspec-test:
|
31
|
-
description: Test rspec in current ruby
|
32
|
-
parameters:
|
33
|
-
pre-steps:
|
34
|
-
description: Necessary steps after checkout
|
35
|
-
type: steps
|
36
|
-
default: []
|
37
|
-
steps:
|
38
|
-
- checkout
|
39
|
-
- run:
|
40
|
-
name: ruby version
|
41
|
-
command: |
|
42
|
-
ruby -e "STDERR.puts RUBY_VERSION; puts RUBY_VERSION.gsub(/^(\d+)\.(\d+)\..*/, '\1_\2')" > .ruby.version
|
43
|
-
- run:
|
44
|
-
name: Gemfile.lock version
|
45
|
-
command: |
|
46
|
-
echo "$GEMFILE.lock" > .Gemfile.lock.path
|
47
|
-
- steps: << parameters.pre-steps >>
|
48
|
-
- restore_cache:
|
49
|
-
keys:
|
50
|
-
- dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
|
51
|
-
- run:
|
52
|
-
name: install dependencies
|
53
|
-
command: |
|
54
|
-
bundle install --jobs=4 --retry=3 --path vendor/bundle --gemfile=$GEMFILE
|
55
|
-
- save_cache:
|
56
|
-
paths:
|
57
|
-
- ./vendor/bundle
|
58
|
-
key: dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
|
59
|
-
- run:
|
60
|
-
name: Disable replication of elastic indices
|
61
|
-
command: |
|
62
|
-
curl -XPUT 'http://localhost:9250/_all/_settings?preserve_existing=true' -d '{
|
63
|
-
"index.number_of_replicas":"0"
|
64
|
-
}'
|
65
|
-
- run:
|
66
|
-
name: run tests
|
67
|
-
command: |
|
68
|
-
ruby -v
|
69
|
-
git config --global user.email "you@example.com"
|
70
|
-
git config --global user.name "Your Name"
|
71
|
-
mkdir /tmp/test-results
|
72
|
-
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
73
|
-
BUNDLE_GEMFILE=$GEMFILE bundle exec rspec --format progress --format RspecJunitFormatter --out /tmp/test-results/rspec.xml $TEST_FILES
|
74
|
-
- store_test_results:
|
75
|
-
path: /tmp/test-results
|
76
|
-
|
77
|
-
jobs:
|
78
|
-
rubocop:
|
79
|
-
docker:
|
80
|
-
- image: circleci/ruby:2.6
|
81
|
-
working_directory: ~/repo
|
82
|
-
steps:
|
83
|
-
- checkout
|
84
|
-
- run:
|
85
|
-
name: ruby version
|
86
|
-
command: |
|
87
|
-
ruby -e "STDERR.puts RUBY_VERSION; puts RUBY_VERSION.gsub(/^(\d+)\.(\d+)\..*/, '\1_\2')" > .ruby.version
|
88
|
-
- run:
|
89
|
-
name: Gemfile.lock version
|
90
|
-
command: |
|
91
|
-
echo "$GEMFILE.lock" > .Gemfile.lock.path
|
92
|
-
- restore_cache:
|
93
|
-
keys:
|
94
|
-
- dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
|
95
|
-
- run:
|
96
|
-
name: install dependencies
|
97
|
-
command: |
|
98
|
-
bundle install --jobs=4 --retry=3 --path vendor/bundle --binstubs=/usr/local/bundle/bin
|
99
|
-
- save_cache:
|
100
|
-
paths:
|
101
|
-
- ./vendor/bundle
|
102
|
-
key: dependencies-{{ checksum ".ruby.version" }}-{{ checksum ".Gemfile.lock.path" }}
|
103
|
-
- run:
|
104
|
-
name: run rubocop
|
105
|
-
command: |
|
106
|
-
bundle exec rubocop --format simple
|
107
|
-
|
108
|
-
rspec-ruby-26-activerecord52:
|
109
|
-
docker:
|
110
|
-
- image: circleci/ruby:2.6
|
111
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
112
|
-
environment:
|
113
|
-
<<: *es-env
|
114
|
-
working_directory: ~/repo
|
115
|
-
environment:
|
116
|
-
GEMFILE: gemfiles/rails.5.2.activerecord.gemfile
|
117
|
-
steps:
|
118
|
-
- rspec-test
|
119
|
-
|
120
|
-
rspec-ruby-26-activerecord60:
|
121
|
-
docker:
|
122
|
-
- image: circleci/ruby:2.6
|
123
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
124
|
-
environment:
|
125
|
-
<<: *es-env
|
126
|
-
working_directory: ~/repo
|
127
|
-
environment:
|
128
|
-
GEMFILE: gemfiles/rails.6.0.activerecord.gemfile
|
129
|
-
steps:
|
130
|
-
- rspec-test
|
131
|
-
|
132
|
-
rspec-ruby-26-activerecord61:
|
133
|
-
docker:
|
134
|
-
- image: circleci/ruby:2.6
|
135
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
136
|
-
environment:
|
137
|
-
<<: *es-env
|
138
|
-
working_directory: ~/repo
|
139
|
-
environment:
|
140
|
-
GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
|
141
|
-
steps:
|
142
|
-
- rspec-test
|
143
|
-
|
144
|
-
rspec-ruby-26-mongoid:
|
145
|
-
docker:
|
146
|
-
- image: circleci/ruby:2.6
|
147
|
-
- image: circleci/mongo:4.2.5
|
148
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
149
|
-
environment:
|
150
|
-
<<: *es-env
|
151
|
-
working_directory: ~/repo
|
152
|
-
environment:
|
153
|
-
GEMFILE: gemfiles/rails.5.2.mongoid.6.4.gemfile
|
154
|
-
steps:
|
155
|
-
- rspec-test
|
156
|
-
|
157
|
-
rspec-ruby-27-activerecord52:
|
158
|
-
docker:
|
159
|
-
- image: circleci/ruby:2.7
|
160
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
161
|
-
environment:
|
162
|
-
<<: *es-env
|
163
|
-
working_directory: ~/repo
|
164
|
-
environment:
|
165
|
-
GEMFILE: gemfiles/rails.5.2.activerecord.gemfile
|
166
|
-
steps:
|
167
|
-
- rspec-test
|
168
|
-
|
169
|
-
rspec-ruby-27-activerecord60:
|
170
|
-
docker:
|
171
|
-
- image: circleci/ruby:2.7
|
172
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
173
|
-
environment:
|
174
|
-
<<: *es-env
|
175
|
-
working_directory: ~/repo
|
176
|
-
environment:
|
177
|
-
GEMFILE: gemfiles/rails.6.0.activerecord.gemfile
|
178
|
-
steps:
|
179
|
-
- rspec-test
|
180
|
-
|
181
|
-
rspec-ruby-27-activerecord61:
|
182
|
-
docker:
|
183
|
-
- image: circleci/ruby:2.7
|
184
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
185
|
-
environment:
|
186
|
-
<<: *es-env
|
187
|
-
working_directory: ~/repo
|
188
|
-
environment:
|
189
|
-
GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
|
190
|
-
steps:
|
191
|
-
- rspec-test
|
192
|
-
|
193
|
-
rspec-ruby-27-mongoid:
|
194
|
-
docker:
|
195
|
-
- image: circleci/ruby:2.7
|
196
|
-
- image: circleci/mongo:4.2.5
|
197
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
198
|
-
environment:
|
199
|
-
<<: *es-env
|
200
|
-
working_directory: ~/repo
|
201
|
-
environment:
|
202
|
-
GEMFILE: gemfiles/rails.5.2.mongoid.6.4.gemfile
|
203
|
-
steps:
|
204
|
-
- rspec-test
|
205
|
-
|
206
|
-
rspec-ruby-30-activerecord61:
|
207
|
-
docker:
|
208
|
-
- image: circleci/ruby:3.0
|
209
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:5.6.7
|
210
|
-
environment:
|
211
|
-
<<: *es-env
|
212
|
-
working_directory: ~/repo
|
213
|
-
environment:
|
214
|
-
GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
|
215
|
-
steps:
|
216
|
-
- rspec-test
|
217
|
-
|
218
|
-
rspec-ruby-27-activerecord61-es6:
|
219
|
-
docker:
|
220
|
-
- image: circleci/ruby:2.7
|
221
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
|
222
|
-
environment:
|
223
|
-
<<: *es-env
|
224
|
-
working_directory: ~/repo
|
225
|
-
environment:
|
226
|
-
GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
|
227
|
-
steps:
|
228
|
-
- rspec-test
|
229
|
-
|
230
|
-
rspec-ruby-30-activerecord61-es6:
|
231
|
-
docker:
|
232
|
-
- image: circleci/ruby:3.0
|
233
|
-
- image: docker.elastic.co/elasticsearch/elasticsearch:6.8.13
|
234
|
-
environment:
|
235
|
-
<<: *es-env
|
236
|
-
working_directory: ~/repo
|
237
|
-
environment:
|
238
|
-
GEMFILE: gemfiles/rails.6.1.activerecord.gemfile
|
239
|
-
steps:
|
240
|
-
- rspec-test
|
data/Appraisals
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
%w[4.0 4.1 4.2].each do |activesupport|
|
2
|
-
appraise "rails.#{activesupport}.activerecord" do
|
3
|
-
gem 'activerecord', "~> #{activesupport}.0"
|
4
|
-
gem 'activesupport', "~> #{activesupport}.0"
|
5
|
-
|
6
|
-
gem 'activejob', "~> #{activesupport}.0" if activesupport >= '4.2'
|
7
|
-
gem 'resque', require: false
|
8
|
-
gem 'shoryuken', require: false
|
9
|
-
gem 'aws-sdk-sqs', require: false
|
10
|
-
gem 'sidekiq', require: false
|
11
|
-
|
12
|
-
gem 'kaminari', '~> 0.17.0', require: false
|
13
|
-
gem 'will_paginate', require: false
|
14
|
-
|
15
|
-
gem 'parallel', require: false
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
%w[5.0 5.1 5.2].each do |activesupport|
|
20
|
-
appraise "rails.#{activesupport}.activerecord" do
|
21
|
-
gem 'activerecord', "~> #{activesupport}.0"
|
22
|
-
gem 'activesupport', "~> #{activesupport}.0"
|
23
|
-
|
24
|
-
gem 'activejob', "~> #{activesupport}.0"
|
25
|
-
gem 'resque', require: false
|
26
|
-
gem 'shoryuken', require: false
|
27
|
-
gem 'aws-sdk-sqs', require: false
|
28
|
-
gem 'sidekiq', require: false
|
29
|
-
|
30
|
-
gem 'kaminari-core', '~> 1.1.0', require: false
|
31
|
-
gem 'will_paginate', require: false
|
32
|
-
|
33
|
-
gem 'parallel', require: false
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
appraise 'rails.4.2.mongoid.5.2' do
|
38
|
-
gem 'mongoid', '~> 5.2.0'
|
39
|
-
gem 'activesupport', '~> 4.2.0'
|
40
|
-
|
41
|
-
gem 'activejob', '~> 4.2.0'
|
42
|
-
gem 'resque', require: false
|
43
|
-
gem 'shoryuken', require: false
|
44
|
-
gem 'aws-sdk-sqs', require: false
|
45
|
-
gem 'sidekiq', require: false
|
46
|
-
|
47
|
-
gem 'kaminari', '~> 0.17.0', require: false
|
48
|
-
gem 'will_paginate', require: false
|
49
|
-
|
50
|
-
gem 'parallel', require: false
|
51
|
-
end
|
52
|
-
|
53
|
-
{'5.0' => '6.1', '5.1' => '6.3'}.each do |activesupport, mongoid|
|
54
|
-
appraise "rails.#{activesupport}.mongoid.#{mongoid}" do
|
55
|
-
gem 'mongoid', "~> #{mongoid}.0"
|
56
|
-
gem 'activesupport', "~> #{activesupport}.0"
|
57
|
-
|
58
|
-
gem 'activejob', "~> #{activesupport}.0"
|
59
|
-
gem 'resque', require: false
|
60
|
-
gem 'shoryuken', require: false
|
61
|
-
gem 'aws-sdk-sqs', require: false
|
62
|
-
gem 'sidekiq', require: false
|
63
|
-
|
64
|
-
gem 'kaminari-core', '~> 1.1.0', require: false
|
65
|
-
gem 'will_paginate', require: false
|
66
|
-
|
67
|
-
gem 'parallel', require: false
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
%w[4.45].each do |sequel|
|
72
|
-
appraise "sequel.#{sequel}" do
|
73
|
-
gem 'sequel', "~> #{sequel}.0"
|
74
|
-
gem 'activesupport', '~> 5.1.0'
|
75
|
-
|
76
|
-
gem 'kaminari-core', '~> 1.1.0', require: false
|
77
|
-
gem 'will_paginate', require: false
|
78
|
-
|
79
|
-
gem 'parallel', require: false
|
80
|
-
end
|
81
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 5.2.0"
|
6
|
-
gem "activesupport", "~> 5.2.0"
|
7
|
-
gem "activejob", "~> 5.2.0"
|
8
|
-
gem "resque", require: false
|
9
|
-
gem "shoryuken", require: false
|
10
|
-
gem "aws-sdk-sqs", require: false
|
11
|
-
gem "sidekiq", require: false
|
12
|
-
gem "kaminari-core", "~> 1.1.0", require: false
|
13
|
-
gem "will_paginate", require: false
|
14
|
-
gem "parallel", require: false
|
15
|
-
gem 'rspec_junit_formatter', '~> 0.4.1'
|
16
|
-
|
17
|
-
gemspec path: "../"
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "mongoid", "~> 6.4.0"
|
6
|
-
gem "activesupport", "~> 5.2.0"
|
7
|
-
gem "activejob", "~> 5.2.0"
|
8
|
-
gem "resque", require: false
|
9
|
-
gem "shoryuken", require: false
|
10
|
-
gem "aws-sdk-sqs", require: false
|
11
|
-
gem "sidekiq", require: false
|
12
|
-
gem "kaminari-core", "~> 1.1.0", require: false
|
13
|
-
gem "will_paginate", require: false
|
14
|
-
gem "parallel", require: false
|
15
|
-
gem 'rspec_junit_formatter', '~> 0.4.1'
|
16
|
-
|
17
|
-
gemspec path: "../"
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 6.0.0"
|
6
|
-
gem "activesupport", "~> 6.0.0"
|
7
|
-
gem "activejob", "~> 6.0.0"
|
8
|
-
gem "resque", require: false
|
9
|
-
gem "shoryuken", require: false
|
10
|
-
gem "aws-sdk-sqs", require: false
|
11
|
-
gem "sidekiq", require: false
|
12
|
-
gem "kaminari-core", "~> 1.1.0", require: false
|
13
|
-
gem "will_paginate", require: false
|
14
|
-
gem "parallel", require: false
|
15
|
-
gem 'rspec_junit_formatter', '~> 0.4.1'
|
16
|
-
|
17
|
-
gemspec path: "../"
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "sequel", "~> 4.45.0"
|
6
|
-
gem "activesupport", "~> 5.1.0"
|
7
|
-
gem "kaminari-core", "~> 1.1.0", require: false
|
8
|
-
gem "will_paginate", require: false
|
9
|
-
gem "parallel", require: false
|
10
|
-
|
11
|
-
gemspec path: "../"
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'chewy/backports/duplicable'
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# Returns a deep copy of object if it's duplicable. If it's
|
5
|
-
# not duplicable, returns +self+.
|
6
|
-
#
|
7
|
-
# object = Object.new
|
8
|
-
# dup = object.deep_dup
|
9
|
-
# dup.instance_variable_set(:@a, 1)
|
10
|
-
#
|
11
|
-
# object.instance_variable_defined?(:@a) # => false
|
12
|
-
# dup.instance_variable_defined?(:@a) # => true
|
13
|
-
def deep_dup
|
14
|
-
duplicable? ? dup : self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Array
|
19
|
-
# Returns a deep copy of array.
|
20
|
-
#
|
21
|
-
# array = [1, [2, 3]]
|
22
|
-
# dup = array.deep_dup
|
23
|
-
# dup[1][2] = 4
|
24
|
-
#
|
25
|
-
# array[1][2] # => nil
|
26
|
-
# dup[1][2] # => 4
|
27
|
-
def deep_dup
|
28
|
-
map(&:deep_dup)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Hash
|
33
|
-
# Returns a deep copy of hash.
|
34
|
-
#
|
35
|
-
# hash = { a: { b: 'b' } }
|
36
|
-
# dup = hash.deep_dup
|
37
|
-
# dup[:a][:c] = 'c'
|
38
|
-
#
|
39
|
-
# hash[:a][:c] # => nil
|
40
|
-
# dup[:a][:c] # => "c"
|
41
|
-
def deep_dup
|
42
|
-
each_with_object(dup) do |(key, value), hash|
|
43
|
-
hash[key.deep_dup] = value.deep_dup
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Most objects are cloneable, but not all. For example you can't dup +nil+:
|
3
|
-
#
|
4
|
-
# nil.dup # => TypeError: can't dup NilClass
|
5
|
-
#
|
6
|
-
# Classes may signal their instances are not duplicable removing +dup+/+clone+
|
7
|
-
# or raising exceptions from them. So, to dup an arbitrary object you normally
|
8
|
-
# use an optimistic approach and are ready to catch an exception, say:
|
9
|
-
#
|
10
|
-
# arbitrary_object.dup rescue object
|
11
|
-
#
|
12
|
-
# Rails dups objects in a few critical spots where they are not that arbitrary.
|
13
|
-
# That rescue is very expensive (like 40 times slower than a predicate), and it
|
14
|
-
# is often triggered.
|
15
|
-
#
|
16
|
-
# That's why we hardcode the following cases and check duplicable? instead of
|
17
|
-
# using that rescue idiom.
|
18
|
-
#++
|
19
|
-
class Object
|
20
|
-
# Can you safely dup this object?
|
21
|
-
#
|
22
|
-
# False for +nil+, +false+, +true+, symbol, and number objects;
|
23
|
-
# true otherwise.
|
24
|
-
def duplicable?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class NilClass
|
30
|
-
# +nil+ is not duplicable:
|
31
|
-
#
|
32
|
-
# nil.duplicable? # => false
|
33
|
-
# nil.dup # => TypeError: can't dup NilClass
|
34
|
-
def duplicable?
|
35
|
-
false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class FalseClass
|
40
|
-
# +false+ is not duplicable:
|
41
|
-
#
|
42
|
-
# false.duplicable? # => false
|
43
|
-
# false.dup # => TypeError: can't dup FalseClass
|
44
|
-
def duplicable?
|
45
|
-
false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class TrueClass
|
50
|
-
# +true+ is not duplicable:
|
51
|
-
#
|
52
|
-
# true.duplicable? # => false
|
53
|
-
# true.dup # => TypeError: can't dup TrueClass
|
54
|
-
def duplicable?
|
55
|
-
false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class Symbol
|
60
|
-
# Symbols are not duplicable:
|
61
|
-
#
|
62
|
-
# :my_symbol.duplicable? # => false
|
63
|
-
# :my_symbol.dup # => TypeError: can't dup Symbol
|
64
|
-
def duplicable?
|
65
|
-
false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class Numeric
|
70
|
-
# Numbers are not duplicable:
|
71
|
-
#
|
72
|
-
# 3.duplicable? # => false
|
73
|
-
# 3.dup # => TypeError: can't dup Fixnum
|
74
|
-
def duplicable?
|
75
|
-
false
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
require 'bigdecimal'
|
80
|
-
class BigDecimal
|
81
|
-
begin
|
82
|
-
BigDecimal('4.56').dup
|
83
|
-
|
84
|
-
def duplicable?
|
85
|
-
true
|
86
|
-
end
|
87
|
-
rescue TypeError
|
88
|
-
# can't dup, so use superclass implementation
|
89
|
-
nil
|
90
|
-
end
|
91
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Chewy
|
2
|
-
module Search
|
3
|
-
module Pagination
|
4
|
-
# This module provides `WillPaginate` support for {Chewy::Search::Request}
|
5
|
-
# It is included automatically if `WillPaginate` is available.
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# PlacesIndex.all.paginate(page: 3, per_page: 10).order(:name)
|
9
|
-
# # => <PlacesIndex::Query {..., :body=>{:size=>10, :from=>20, :sort=>["name"]}}>
|
10
|
-
module WillPaginate
|
11
|
-
extend ActiveSupport::Concern
|
12
|
-
|
13
|
-
included do
|
14
|
-
include ::WillPaginate::CollectionMethods
|
15
|
-
attr_reader :current_page, :per_page
|
16
|
-
end
|
17
|
-
|
18
|
-
def paginate(options = {})
|
19
|
-
@current_page = ::WillPaginate::PageNumber(options[:page] || @current_page || 1)
|
20
|
-
@page_multiplier = @current_page - 1
|
21
|
-
@per_page = (options[:per_page] || @per_page || ::WillPaginate.per_page).to_i
|
22
|
-
|
23
|
-
# call Chewy::Search::Request methods to limit results
|
24
|
-
limit(@per_page).offset(@page_multiplier * @per_page)
|
25
|
-
end
|
26
|
-
|
27
|
-
def page(page)
|
28
|
-
paginate(page: page)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def paginated_collection(collection)
|
34
|
-
page = current_page || 1
|
35
|
-
per = per_page || ::WillPaginate.per_page
|
36
|
-
::WillPaginate::Collection.create(page, per, total_entries) do |pager|
|
37
|
-
pager.replace collection
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'chewy/search/parameters/storage'
|
2
|
-
|
3
|
-
module Chewy
|
4
|
-
module Search
|
5
|
-
class Parameters
|
6
|
-
# A standard string array storage with one exception: rendering is empty.
|
7
|
-
#
|
8
|
-
# @see Chewy::Search::Parameters::StringArrayStorage
|
9
|
-
class Types < Storage
|
10
|
-
include StringArrayStorage
|
11
|
-
|
12
|
-
# Doesn't render anything, has specialized rendering logic in
|
13
|
-
# {Chewy::Search::Request}
|
14
|
-
#
|
15
|
-
# @return [nil]
|
16
|
-
def render; end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Chewy
|
2
|
-
class Strategy
|
3
|
-
# The strategy works the same way as atomic, but performs
|
4
|
-
# async index update driven by resque
|
5
|
-
#
|
6
|
-
# Chewy.strategy(:resque) do
|
7
|
-
# User.all.map(&:save) # Does nothing here
|
8
|
-
# Post.all.map(&:save) # And here
|
9
|
-
# # It imports all the changed users and posts right here
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
class Resque < Atomic
|
13
|
-
class Worker
|
14
|
-
@queue = :chewy
|
15
|
-
|
16
|
-
def self.perform(type, ids, options = {})
|
17
|
-
options[:refresh] = !Chewy.disable_refresh_async if Chewy.disable_refresh_async
|
18
|
-
type.constantize.import!(ids, options)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def leave
|
23
|
-
@stash.all? { |type, ids| ::Resque.enqueue(Chewy::Strategy::Resque::Worker, type.name, ids) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Chewy
|
2
|
-
class Strategy
|
3
|
-
# The strategy works the same way as atomic, but performs
|
4
|
-
# async index update driven by shoryuken
|
5
|
-
#
|
6
|
-
# Chewy.strategy(:shoryuken) do
|
7
|
-
# User.all.map(&:save) # Does nothing here
|
8
|
-
# Post.all.map(&:save) # And here
|
9
|
-
# # It imports all the changed users and posts right here
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
class Shoryuken < Atomic
|
13
|
-
class Worker
|
14
|
-
include ::Shoryuken::Worker
|
15
|
-
|
16
|
-
shoryuken_options auto_delete: true,
|
17
|
-
body_parser: :json
|
18
|
-
|
19
|
-
def perform(_sqs_msg, body)
|
20
|
-
options = body['options'] || {}
|
21
|
-
options[:refresh] = !Chewy.disable_refresh_async if Chewy.disable_refresh_async
|
22
|
-
body['type'].constantize.import!(body['ids'], options.deep_symbolize_keys!)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def leave
|
27
|
-
@stash.each do |type, ids|
|
28
|
-
next if ids.empty?
|
29
|
-
Shoryuken::Worker.perform_async({type: type.name, ids: ids}, queue: shoryuken_queue)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
private
|
34
|
-
|
35
|
-
def shoryuken_queue
|
36
|
-
Chewy.settings.fetch(:shoryuken, {})[:queue] || 'chewy'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|