chewy 7.3.0 → 7.3.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: fcd795c985f120c412c315bc0b87dd65e7b55a302aeae1bffbc5c71beb910652
4
- data.tar.gz: ad70c5ff382f8405146da2be5643d9ac397d60fbbf16842a509a950cc90acbd2
3
+ metadata.gz: 4fce5e949350a7256e302f88e4f085e186b41b947944bfca3278bc6b63d308f7
4
+ data.tar.gz: 1454ca0cb5550ce118de31b37bbd05dca8c7c0a07c0cc78cd75552e6fbcead30
5
5
  SHA512:
6
- metadata.gz: 0f4ac34a7c84c9fc6dd2743ab77982b634bddb0ceda0116b2a2bfa9a0b902655b375bc215857002041159a5cd0ce52e9c409342f06ce7a41f0667d3c74c07ab4
7
- data.tar.gz: fa68110ccfc6acd942c54b279cfd99e36b980dcb408bd1508430598757c3efd57e8dc1eaa60c2bf77156eb9acba77c700715ac9676af0a36eacb600de730b1b5
6
+ metadata.gz: c4ec988d938d54bcb934007bf43d1f6035c474b425718cc3ad38e092aebc46213da79e911d8bd8861fa3af8fa36200d4e05b351cb01b6f647aac36a172123b39
7
+ data.tar.gz: 674648b1ace4d6f72d54a1e4efdc5984e49b270da1a89e52cf42f6b8b4f539a9e55f6ca5e9970ac494208f67b970cc0c280241d560067f79c238ffce5ad680f4
data/CHANGELOG.md CHANGED
@@ -8,6 +8,23 @@
8
8
 
9
9
  ### Bugs Fixed
10
10
 
11
+ ## 7.3.2 (2023-04-20)
12
+
13
+ ### New Features
14
+
15
+ ### Changes
16
+
17
+ ### Bugs Fixed
18
+
19
+ * [#861](https://github.com/toptal/chewy/pull/861): Fix bug in mock_elasticsearch_response_sources ([@lafeber](https://github.com/lafeber))
20
+
21
+ ## 7.3.1 (2023-04-20)
22
+
23
+ ### Bugs Fixed
24
+
25
+ * [#874](https://github.com/toptal/chewy/pull/874): Fix `chewy:journal:clean` task for ruby 3.x. ([@muk-ai](https://github.com/muk-ai))
26
+ * [#882](https://github.com/toptal/chewy/pull/882): Fix memory leak during `chewy:reset` for ruby 3.2 ([@konalegi](https://github.com/konalegi))
27
+
11
28
  ## 7.3.0 (2023-04-03)
12
29
 
13
30
  ### New Features
data/README.md CHANGED
@@ -503,7 +503,7 @@ class ProductsIndex < Chewy::Index
503
503
 
504
504
  field :name
505
505
  # simply use crutch-fetched data as a value:
506
- field :category_names, value: ->(product, crutches) { crutches.categories[product.id] }
506
+ field :category_names, value: ->(product, crutches) { crutches[:categories][product.id] }
507
507
  end
508
508
  ```
509
509
 
@@ -884,7 +884,9 @@ It is convenient for use in e.g. the Rails console with non-block notation:
884
884
 
885
885
  #### `:bypass`
886
886
 
887
- The bypass strategy simply silences index updates.
887
+ When the bypass strategy is active the index will not be automatically updated on object save.
888
+
889
+ For example, on `City.first.save!` the cities index would not be updated.
888
890
 
889
891
  #### Nesting
890
892
 
@@ -12,13 +12,21 @@ module Chewy
12
12
  def initialize(index, collection)
13
13
  @index = index
14
14
  @collection = collection
15
- @index._crutches.each_key do |name|
16
- singleton_class.class_eval <<-METHOD, __FILE__, __LINE__ + 1
17
- def #{name}
18
- @#{name} ||= @index._crutches[:#{name}].call @collection
19
- end
20
- METHOD
21
- end
15
+ @crutches_instances = {}
16
+ end
17
+
18
+ def method_missing(name, *, **)
19
+ return self[name] if @index._crutches.key?(name)
20
+
21
+ super
22
+ end
23
+
24
+ def respond_to_missing?(name, include_private = false)
25
+ @index._crutches.key?(name) || super
26
+ end
27
+
28
+ def [](name)
29
+ @crutches_instances[name] ||= @index._crutches[:"#{name}"].call(@collection)
22
30
  end
23
31
  end
24
32
 
@@ -97,7 +97,7 @@ module Chewy
97
97
  {
98
98
  '_index' => index.index_name,
99
99
  '_type' => '_doc',
100
- '_id' => (i + 1).to_s,
100
+ '_id' => hit[:id] || (i + 1).to_s,
101
101
  '_score' => 3.14,
102
102
  '_source' => hit
103
103
  }
data/lib/chewy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '7.3.0'.freeze
2
+ VERSION = '7.3.2'.freeze
3
3
  end
data/lib/tasks/chewy.rake CHANGED
@@ -96,7 +96,7 @@ namespace :chewy do
96
96
  task clean: :environment do |_task, args|
97
97
  delete_options = Chewy::RakeHelper.delete_by_query_options_from_env(ENV)
98
98
  Chewy::RakeHelper.journal_clean(
99
- [
99
+ **[
100
100
  parse_journal_args(args.extras),
101
101
  {delete_by_query_options: delete_options}
102
102
  ].reduce({}, :merge)
@@ -32,14 +32,14 @@ describe :minitest_helper do
32
32
  {
33
33
  '_index' => 'dummies',
34
34
  '_type' => '_doc',
35
- '_id' => '1',
35
+ '_id' => '2',
36
36
  '_score' => 3.14,
37
37
  '_source' => source
38
38
  }
39
39
  ]
40
40
  end
41
41
 
42
- let(:source) { {'name' => 'some_name'} }
42
+ let(:source) { {'name' => 'some_name', id: '2'} }
43
43
  let(:sources) { [source] }
44
44
 
45
45
  context 'mocks by raw response' do
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'rake'
2
3
 
3
4
  describe Chewy::RakeHelper, :orm do
4
5
  before { Chewy.massacre }
@@ -456,6 +457,17 @@ Total: \\d+s\\Z
456
457
  Total: \\d+s\\Z
457
458
  OUTPUT
458
459
  end
460
+
461
+ context 'execute "chewy:journal:clean" rake task' do
462
+ subject(:task) { Rake.application['chewy:journal:clean'] }
463
+ before do
464
+ Rake::DefaultLoader.new.load('lib/tasks/chewy.rake')
465
+ Rake::Task.define_task(:environment)
466
+ end
467
+ it 'does not raise error' do
468
+ expect { task.invoke }.to_not raise_error
469
+ end
470
+ end
459
471
  end
460
472
 
461
473
  describe '.reindex' do
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.0
4
+ version: 7.3.2
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-04-03 00:00:00.000000000 Z
12
+ date: 2023-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: database_cleaner