algoliasearch-rails 1.11.2 → 1.11.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
  SHA1:
3
- metadata.gz: 5e8dd1f75b435b4e192ce211b00c399417b42689
4
- data.tar.gz: e211db3fc43bc4fa55ab38c6ec2e860a037cea10
3
+ metadata.gz: 5d30fc03ca7d3eff1c03acba69d072d537b05490
4
+ data.tar.gz: be2943752a81bec8523b6259d0808703bb280cda
5
5
  SHA512:
6
- metadata.gz: e12c15de1151b7fc6e3fb5d69486844bbe2216769be212d60ebcd8f127d0b9b1b76416c8d1e85bf5fbd3671ba88f1e259b3801a2ec5d6f47aa2235aaa4f2ce9f
7
- data.tar.gz: f6103d4b36d27ee3d2133280edc9e16d50e4bdbb09b6287d66f866afe47f39bf2255f7a8a08a15186b175b95ad9338d4517827d478a8721a3d4ce8251ea41fac
6
+ metadata.gz: a1789ee695aca9675cf336449c068e7cc7af92da6c5b1a4cca93c05eb443bceb71a77fba39915933e58498dac1e69efc8a845c59b014e253dc1ecd94b40539d3
7
+ data.tar.gz: b6989c9492c3594823e6b39ed69600cd0172d88b00e6de30fea0a1ee8737424cd5d5c69a5e7532aeb06b1214f964d1057adf7e17cfe32c67a9242652ed2d9d75
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
+ 2014-09-16 1.11.3
4
+
5
+ * While reindexing, fetch the master's settings to setup the temporary index
6
+
3
7
  2014-09-02 1.11.2
4
8
 
5
9
  * Ability to search in a slave or extra index using the ```:index```/```:slave``` parameter
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.11.2
1
+ 1.11.3
@@ -6,11 +6,11 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch-rails"
9
- s.version = "1.11.2"
9
+ s.version = "1.11.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Algolia"]
13
- s.date = "2014-09-02"
13
+ s.date = "2014-09-16"
14
14
  s.description = "AlgoliaSearch integration to your favorite ORM"
15
15
  s.email = "contact@algolia.com"
16
16
  s.extra_rdoc_files = [
@@ -257,11 +257,21 @@ module AlgoliaSearch
257
257
  algolia_configurations.each do |options, settings|
258
258
  next if algolia_indexing_disabled?(options)
259
259
  next if options[:slave]
260
- index_name = algolia_index_name(options)
261
260
 
261
+ # fetch the master settings
262
+ master_index = algolia_ensure_init(options, settings)
263
+ master_settings = master_index.get_settings rescue {} # if master doesn't exist yet
264
+ master_settings.merge!(JSON.parse(settings.to_settings.to_json)) # convert symbols to strings
265
+
266
+ # remove the slaves of the temporary index
267
+ master_settings.delete :slaves
268
+ master_settings.delete 'slaves'
269
+
270
+ # init temporary index
271
+ index_name = algolia_index_name(options)
262
272
  tmp_options = options.merge({ :index_name => "#{index_name}.tmp" })
263
273
  tmp_settings = settings.dup
264
- tmp_index = algolia_ensure_init(tmp_options, tmp_settings, true)
274
+ tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
265
275
 
266
276
  algolia_find_in_batches(batch_size) do |group|
267
277
  if algolia_conditional_index?(tmp_options)
@@ -439,19 +449,15 @@ module AlgoliaSearch
439
449
 
440
450
  protected
441
451
 
442
- def algolia_ensure_init(options = nil, settings = nil, remove_slaves = false)
452
+ def algolia_ensure_init(options = nil, settings = nil, index_settings = nil)
443
453
  @algolia_indexes ||= {}
444
454
  options ||= algoliasearch_options
445
455
  settings ||= algoliasearch_settings
446
456
  return @algolia_indexes[settings] if @algolia_indexes[settings]
447
457
  @algolia_indexes[settings] = Algolia::Index.new(algolia_index_name(options))
448
458
  current_settings = @algolia_indexes[settings].get_settings rescue nil # if the index doesn't exist
449
- if !algolia_indexing_disabled?(options) && algoliasearch_settings_changed?(current_settings, settings.to_settings)
450
- index_settings = settings.to_settings
451
- if remove_slaves
452
- index_settings.delete :slaves
453
- index_settings.delete 'slaves'
454
- end
459
+ if !algolia_indexing_disabled?(options) && (index_settings || algoliasearch_settings_changed?(current_settings, settings.to_settings))
460
+ index_settings ||= settings.to_settings
455
461
  @algolia_indexes[settings].set_settings(index_settings)
456
462
  end
457
463
  @algolia_indexes[settings]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.2
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json