chewy 7.3.3 → 7.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +42 -0
- data/.github/workflows/ruby.yml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +4 -0
- data/gemfiles/rails.7.1.activerecord.gemfile +13 -0
- data/lib/chewy/log_subscriber.rb +5 -1
- data/lib/chewy/rake_helper.rb +18 -0
- data/lib/chewy/version.rb +1 -1
- data/lib/chewy.rb +1 -0
- data/lib/tasks/chewy.rake +5 -0
- data/spec/chewy/rake_helper_spec.rb +53 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcb16d3ca40da336d2445b114cff68c634f6091c66352f459bafbce6794aa864
|
4
|
+
data.tar.gz: bedb5bcc0520a6e6b26c9605cd2574a102469d6043f9ce39c55aeae61d1fa30b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46eef11ff1d3acf7d3717fa5975071f06ae0fa03f638c82be7f5e687efababf39c67d1cfd7d376854c556ea0227876743b5e7e0ac845df1f72f1ea8bab510d70
|
7
|
+
data.tar.gz: '0889aee5bc0d928dbff9b1894064c5fe3f8a572b7f3e434034b8fe32a7bcece1d48a86673cad80fcc40b2a6a41342f7195905d90d87e7f6a85d9bb5e1b8ab4a2'
|
@@ -0,0 +1,42 @@
|
|
1
|
+
version: 2
|
2
|
+
registries:
|
3
|
+
toptal-github:
|
4
|
+
type: "git"
|
5
|
+
url: "https://github.com"
|
6
|
+
username: "x-access-token"
|
7
|
+
password: "${{secrets.DEPENDABOT_GITHUB_TOKEN}}"
|
8
|
+
|
9
|
+
updates:
|
10
|
+
- package-ecosystem: bundler
|
11
|
+
directory: "/"
|
12
|
+
schedule:
|
13
|
+
interval: "weekly"
|
14
|
+
day: "wednesday"
|
15
|
+
time: "07:00"
|
16
|
+
pull-request-branch-name:
|
17
|
+
separator: "-"
|
18
|
+
labels:
|
19
|
+
- "no-jira"
|
20
|
+
- "ruby"
|
21
|
+
- "dependencies"
|
22
|
+
reviewers:
|
23
|
+
- "toptal/devx"
|
24
|
+
registries:
|
25
|
+
- toptal-github
|
26
|
+
insecure-external-code-execution: allow
|
27
|
+
open-pull-requests-limit: 3
|
28
|
+
- package-ecosystem: "github-actions"
|
29
|
+
directory: "/"
|
30
|
+
schedule:
|
31
|
+
interval: "weekly"
|
32
|
+
day: "wednesday"
|
33
|
+
time: "07:00"
|
34
|
+
pull-request-branch-name:
|
35
|
+
separator: "-"
|
36
|
+
labels:
|
37
|
+
- "no-jira"
|
38
|
+
- "dependencies"
|
39
|
+
- "gha"
|
40
|
+
reviewers:
|
41
|
+
- "toptal/devx"
|
42
|
+
open-pull-requests-limit: 3
|
data/.github/workflows/ruby.yml
CHANGED
@@ -24,7 +24,7 @@ jobs:
|
|
24
24
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
25
25
|
|
26
26
|
steps:
|
27
|
-
- uses: actions/checkout@
|
27
|
+
- uses: actions/checkout@v4
|
28
28
|
- uses: ruby/setup-ruby@v1
|
29
29
|
with:
|
30
30
|
ruby-version: ${{ matrix.ruby }}
|
@@ -43,14 +43,14 @@ jobs:
|
|
43
43
|
fail-fast: false
|
44
44
|
matrix:
|
45
45
|
ruby: [ '3.0', '3.1', '3.2' ]
|
46
|
-
gemfile: [ rails.6.1.activerecord, rails.7.0.activerecord ]
|
46
|
+
gemfile: [ rails.6.1.activerecord, rails.7.0.activerecord, rails.7.1.activerecord ]
|
47
47
|
name: ${{ matrix.ruby }}-${{ matrix.gemfile }}
|
48
48
|
|
49
49
|
env:
|
50
50
|
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
51
51
|
|
52
52
|
steps:
|
53
|
-
- uses: actions/checkout@
|
53
|
+
- uses: actions/checkout@v4
|
54
54
|
- uses: ruby/setup-ruby@v1
|
55
55
|
with:
|
56
56
|
ruby-version: ${{ matrix.ruby }}
|
@@ -66,7 +66,7 @@ jobs:
|
|
66
66
|
rubocop:
|
67
67
|
runs-on: ubuntu-latest
|
68
68
|
steps:
|
69
|
-
- uses: actions/checkout@
|
69
|
+
- uses: actions/checkout@v4
|
70
70
|
- uses: ruby/setup-ruby@v1
|
71
71
|
with:
|
72
72
|
ruby-version: 2.7
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,26 @@
|
|
8
8
|
|
9
9
|
### Bugs Fixed
|
10
10
|
|
11
|
+
## 7.3.5 (2023-12-06)
|
12
|
+
|
13
|
+
### New Features
|
14
|
+
|
15
|
+
* [#907](https://github.com/toptal/chewy/pull/907): Fix deprecation warning in LogSubscriber for Rails 7.1 ([@alejandroperea](https://github.com/alejandroperea))
|
16
|
+
|
17
|
+
### Changes
|
18
|
+
|
19
|
+
### Bugs Fixed
|
20
|
+
|
21
|
+
## 7.3.4 (2023-08-29)
|
22
|
+
|
23
|
+
### New Features
|
24
|
+
|
25
|
+
* [#888](https://github.com/toptal/chewy/pull/892): Rake task to create missing indexes ([@konalegi](https://github.com/konalegi))
|
26
|
+
|
27
|
+
### Changes
|
28
|
+
|
29
|
+
### Bugs Fixed
|
30
|
+
|
11
31
|
## 7.3.3 (2023-07-07)
|
12
32
|
|
13
33
|
### New Features
|
data/README.md
CHANGED
@@ -1197,6 +1197,10 @@ Right now the approach is that if some data had been updated, but index definiti
|
|
1197
1197
|
|
1198
1198
|
Also, there is always full reset alternative with `rake chewy:reset`.
|
1199
1199
|
|
1200
|
+
#### `chewy:create_missing_indexes`
|
1201
|
+
|
1202
|
+
This rake task creates newly defined indexes in ElasticSearch and skips existing ones. Useful for production-like environments.
|
1203
|
+
|
1200
1204
|
#### Parallelizing rake tasks
|
1201
1205
|
|
1202
1206
|
Every task described above has its own parallel version. Every parallel rake task takes the number for processes for execution as the first argument and the rest of the arguments are exactly the same as for the non-parallel task version.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'activejob', '~> 7.1.0'
|
4
|
+
gem 'activerecord', '~> 7.1.0'
|
5
|
+
gem 'activesupport', '~> 7.1.0'
|
6
|
+
gem 'kaminari-core', '~> 1.1.0', require: false
|
7
|
+
gem 'parallel', require: false
|
8
|
+
gem 'rspec_junit_formatter', '~> 0.4.1'
|
9
|
+
gem 'sidekiq', require: false
|
10
|
+
|
11
|
+
gem 'rexml' if RUBY_VERSION >= '3.0.0'
|
12
|
+
|
13
|
+
gemspec path: '../'
|
data/lib/chewy/log_subscriber.rb
CHANGED
@@ -24,7 +24,11 @@ module Chewy
|
|
24
24
|
|
25
25
|
subject = payload[:type].presence || payload[:index]
|
26
26
|
action = "#{subject} #{action} (#{event.duration.round(1)}ms)"
|
27
|
-
action =
|
27
|
+
action = if ActiveSupport.version >= Gem::Version.new('7.1')
|
28
|
+
color(action, GREEN, bold: true)
|
29
|
+
else
|
30
|
+
color(action, GREEN, true)
|
31
|
+
end
|
28
32
|
|
29
33
|
debug(" #{action} #{description}")
|
30
34
|
end
|
data/lib/chewy/rake_helper.rb
CHANGED
@@ -268,6 +268,24 @@ module Chewy
|
|
268
268
|
end
|
269
269
|
end
|
270
270
|
|
271
|
+
def create_missing_indexes!(output: $stdout, env: ENV)
|
272
|
+
subscribed_task_stats(output) do
|
273
|
+
Chewy.eager_load!
|
274
|
+
all_indexes = Chewy::Index.descendants
|
275
|
+
all_indexes -= [Chewy::Stash::Journal] unless Chewy.configuration[:journal]
|
276
|
+
all_indexes.each do |index|
|
277
|
+
if index.exists?
|
278
|
+
output.puts "#{index.name} already exists, skipping" if env['VERBOSE']
|
279
|
+
next
|
280
|
+
end
|
281
|
+
|
282
|
+
index.create!
|
283
|
+
|
284
|
+
output.puts "#{index.name} index successfully created"
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
271
289
|
def normalize_indexes(*identifiers)
|
272
290
|
identifiers.flatten(1).map { |identifier| normalize_index(identifier) }
|
273
291
|
end
|
data/lib/chewy/version.rb
CHANGED
data/lib/chewy.rb
CHANGED
data/lib/tasks/chewy.rake
CHANGED
@@ -57,6 +57,11 @@ namespace :chewy do
|
|
57
57
|
Chewy::RakeHelper.update_mapping(name: args[:index_name])
|
58
58
|
end
|
59
59
|
|
60
|
+
desc 'Creates missing indexes'
|
61
|
+
task create_missing_indexes: :environment do
|
62
|
+
Chewy::RakeHelper.create_missing_indexes!
|
63
|
+
end
|
64
|
+
|
60
65
|
namespace :parallel do
|
61
66
|
desc 'Parallel version of `rake chewy:reset`'
|
62
67
|
task reset: :environment do |_task, args|
|
@@ -470,6 +470,59 @@ Total: \\d+s\\Z
|
|
470
470
|
end
|
471
471
|
end
|
472
472
|
|
473
|
+
describe '.create_missing_indexes!' do
|
474
|
+
before do
|
475
|
+
[CountriesIndex, Chewy::Stash::Specification].map(&:create!)
|
476
|
+
|
477
|
+
# To avoid flaky issues when previous specs were run
|
478
|
+
expect(Chewy::Index).to receive(:descendants).and_return(
|
479
|
+
[
|
480
|
+
UsersIndex,
|
481
|
+
CountriesIndex,
|
482
|
+
CitiesIndex,
|
483
|
+
Chewy::Stash::Specification,
|
484
|
+
Chewy::Stash::Journal
|
485
|
+
]
|
486
|
+
)
|
487
|
+
end
|
488
|
+
|
489
|
+
specify do
|
490
|
+
output = StringIO.new
|
491
|
+
described_class.create_missing_indexes!(output: output)
|
492
|
+
expect(CitiesIndex.exists?).to be_truthy
|
493
|
+
expect(UsersIndex.exists?).to be_truthy
|
494
|
+
expect(Chewy::Stash::Journal.exists?).to be_falsey
|
495
|
+
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
496
|
+
UsersIndex index successfully created
|
497
|
+
CitiesIndex index successfully created
|
498
|
+
Total: \\d+s\\Z
|
499
|
+
OUTPUT
|
500
|
+
end
|
501
|
+
|
502
|
+
context 'when verbose' do
|
503
|
+
specify do
|
504
|
+
output = StringIO.new
|
505
|
+
described_class.create_missing_indexes!(output: output, env: {'VERBOSE' => '1'})
|
506
|
+
expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
|
507
|
+
UsersIndex index successfully created
|
508
|
+
CountriesIndex already exists, skipping
|
509
|
+
CitiesIndex index successfully created
|
510
|
+
Chewy::Stash::Specification already exists, skipping
|
511
|
+
Total: \\d+s\\Z
|
512
|
+
OUTPUT
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
context 'when journaling is enabled' do
|
517
|
+
before { Chewy.config.settings[:journal] = true }
|
518
|
+
after { Chewy.config.settings.delete(:journal) }
|
519
|
+
specify do
|
520
|
+
described_class.create_missing_indexes!(output: StringIO.new)
|
521
|
+
expect(Chewy::Stash::Journal.exists?).to be_truthy
|
522
|
+
end
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
473
526
|
describe '.journal_create' do
|
474
527
|
specify do
|
475
528
|
output = StringIO.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chewy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.3.
|
4
|
+
version: 7.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toptal, LLC
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: database_cleaner
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
241
241
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
242
242
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
243
|
+
- ".github/dependabot.yml"
|
243
244
|
- ".github/workflows/ruby.yml"
|
244
245
|
- ".gitignore"
|
245
246
|
- ".rspec"
|
@@ -260,6 +261,7 @@ files:
|
|
260
261
|
- gemfiles/rails.6.0.activerecord.gemfile
|
261
262
|
- gemfiles/rails.6.1.activerecord.gemfile
|
262
263
|
- gemfiles/rails.7.0.activerecord.gemfile
|
264
|
+
- gemfiles/rails.7.1.activerecord.gemfile
|
263
265
|
- lib/chewy.rb
|
264
266
|
- lib/chewy/config.rb
|
265
267
|
- lib/chewy/errors.rb
|