chewy 7.3.1 → 7.3.3

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: 79428eb9af436a7a4c80a2db3c034583768eacc45d00074525f8e6559341ae20
4
- data.tar.gz: 23377b8abb6ebfa81f8140990916022f8bbca769b5ad4474a076c8d890ece979
3
+ metadata.gz: 60e69fe04eed332db4c9ce826c821609a19745f093a12d396d30a25e7785ae4a
4
+ data.tar.gz: fe8112b8ff752725b4535ad32ffac4483fc210bd4250de92c26251a04e94890b
5
5
  SHA512:
6
- metadata.gz: 89b6aa83fa54a6b5056623f8255eb34675ad9c3e1494915aa324af752d1a72f9c010fcbcbb3c929a232b32811bbc36956624848efabc09cb382c59fbcee54940
7
- data.tar.gz: 90e1da06cf5c38903ca52c6b5379a9271cf277e3c70604b80d77d9ed13496b15ac3874249f2bf67fca7aec3eb9ac9db5e9a20de95eb1da7bb1bfa84307c9c846
6
+ metadata.gz: 78188a2f073d618aafc5b5677694196c9f4102be5530873a49514bc1bddd93fef87394238ea4220746671a9ea112c9df8b9ada89b41ca56d32b7bc2dfe72f451
7
+ data.tar.gz: 207b683ccfc886536cf626e8621b1b6dece73bb155251109d9a226e2a9583516bdc7cfedcc140ddbc1c0e2b4893965668a9c4a803baa5e0907c1dfa20dd0fe27
data/CHANGELOG.md CHANGED
@@ -8,6 +8,26 @@
8
8
 
9
9
  ### Bugs Fixed
10
10
 
11
+ ## 7.3.3 (2023-07-07)
12
+
13
+ ### New Features
14
+
15
+ * [#888](https://github.com/toptal/chewy/pull/888/files): Skip journal creation on import ([@konalegi](https://github.com/konalegi))
16
+
17
+ ### Changes
18
+
19
+ ### Bugs Fixed
20
+
21
+ ## 7.3.2 (2023-04-20)
22
+
23
+ ### New Features
24
+
25
+ ### Changes
26
+
27
+ ### Bugs Fixed
28
+
29
+ * [#861](https://github.com/toptal/chewy/pull/861): Fix bug in mock_elasticsearch_response_sources ([@lafeber](https://github.com/lafeber))
30
+
11
31
  ## 7.3.1 (2023-04-20)
12
32
 
13
33
  ### Bugs Fixed
@@ -64,7 +64,7 @@ module Chewy
64
64
  # Creates the journal index and the corresponding index if necessary.
65
65
  # @return [Object] whatever
66
66
  def create_indexes!
67
- Chewy::Stash::Journal.create if @options[:journal]
67
+ Chewy::Stash::Journal.create if @options[:journal] && !Chewy.configuration[:skip_journal_creation_on_import]
68
68
  return if Chewy.configuration[:skip_index_creation_on_import]
69
69
 
70
70
  @index.create!(**@bulk_options.slice(:suffix)) unless @index.exists?
@@ -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
  }
@@ -197,6 +197,19 @@ module Chewy
197
197
  end
198
198
  end
199
199
 
200
+ # Creates journal index.
201
+ #
202
+ # @example
203
+ # Chewy::RakeHelper.journal_create # creates journal
204
+ #
205
+ # @param output [IO] output io for logging
206
+ # @return Chewy::Index Returns instance of chewy index
207
+ def journal_create(output: $stdout)
208
+ subscribed_task_stats(output) do
209
+ Chewy::Stash::Journal.create!
210
+ end
211
+ end
212
+
200
213
  # Eager loads and returns all the indexes defined in the application
201
214
  # except Chewy::Stash::Specification and Chewy::Stash::Journal.
202
215
  #
data/lib/chewy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chewy
2
- VERSION = '7.3.1'.freeze
2
+ VERSION = '7.3.3'.freeze
3
3
  end
data/lib/tasks/chewy.rake CHANGED
@@ -87,6 +87,11 @@ namespace :chewy do
87
87
  end
88
88
 
89
89
  namespace :journal do
90
+ desc 'Create manually journal, useful when `skip_journal_creation_on_import` is used'
91
+ task create: :environment do |_task, _args|
92
+ Chewy::RakeHelper.journal_create
93
+ end
94
+
90
95
  desc 'Applies changes that were done after the specified time for the specified indexes/types or all of them'
91
96
  task apply: :environment do |_task, args|
92
97
  Chewy::RakeHelper.journal_apply(**parse_journal_args(args.extras))
@@ -60,6 +60,19 @@ describe Chewy::Index::Import do
60
60
  CitiesIndex.import(dummy_city)
61
61
  end
62
62
  end
63
+
64
+ context 'skip journal creation on import' do
65
+ before do
66
+ Chewy::Stash::Journal.create!
67
+ Chewy.config.settings[:skip_journal_creation_on_import] = true
68
+ end
69
+ after { Chewy.config.settings[:skip_journal_creation_on_import] = nil }
70
+
71
+ specify do
72
+ expect(Chewy::Stash::Journal).not_to receive(:create!)
73
+ CitiesIndex.import(dummy_city, journal: true)
74
+ end
75
+ end
63
76
  end
64
77
 
65
78
  shared_examples 'importing' do
@@ -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
@@ -470,6 +470,17 @@ Total: \\d+s\\Z
470
470
  end
471
471
  end
472
472
 
473
+ describe '.journal_create' do
474
+ specify do
475
+ output = StringIO.new
476
+ described_class.journal_create(output: output)
477
+ expect(Chewy::Stash::Journal.exists?).to be_truthy
478
+ expect(output.string).to match(Regexp.new(<<-OUTPUT, Regexp::MULTILINE))
479
+ Total: \\d+s\\Z
480
+ OUTPUT
481
+ end
482
+ end
483
+
473
484
  describe '.reindex' do
474
485
  before do
475
486
  journal
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.1
4
+ version: 7.3.3
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-20 00:00:00.000000000 Z
12
+ date: 2023-07-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: database_cleaner
@@ -482,7 +482,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
482
482
  - !ruby/object:Gem::Version
483
483
  version: '0'
484
484
  requirements: []
485
- rubygems_version: 3.3.26
485
+ rubygems_version: 3.4.10
486
486
  signing_key:
487
487
  specification_version: 4
488
488
  summary: Elasticsearch ODM client wrapper