algoliasearch-rails 1.3.4 → 1.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cdbcc449354c8cdb2735703c5084715b838b85fc
4
- data.tar.gz: c582acfeb65aaf4bd47f27be2368b5377bb901e5
3
+ metadata.gz: d725221ebe1951d7402c2ebd39d0d3a5f842d492
4
+ data.tar.gz: 7bd0b0ffbf077922c58435ae10723b098bda4eba
5
5
  SHA512:
6
- metadata.gz: 05405690f066188e732cf7de198a9ece32f4cae75e635b42d7d9cad7e5d8f1d1db465d323d69b57dddb8a92fd5d79733fe95511d428880f6e6729222c1de3cb8
7
- data.tar.gz: eadeaaa3d98e49954973397ca30533b7f1a07a3537742dd618bb2a00947026c08b35429d912c84d8aabc7007ea9409db95126878832ddda1845786b97c2a2851
6
+ metadata.gz: 37fe184cd8ee01faa96adcdbcc3d1fe8665d03ec5957798828ebf04753f2e9e42a8118f2b52597eaedef67114a432134f61df0aafd697062f53d9edf17b1987f
7
+ data.tar.gz: d51d0d58a0e07e3920a7ee280525036ed77548432e7793ad85cc6f39f4504cb72b770eec2e08541e4bb4e91f827413584b7131e339c50aa49c213c56558d2e54
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
+ 2013-11-07 1.3.5
4
+
5
+ * add without_auto_index_scope method disabling all indexing operations inside associated block
6
+
3
7
  2013-11-07 1.3.4
4
8
 
5
9
  * updated algoliasearch to 1.1.6 (clear_index! is now a real clear, not a delete/create) and algoliasearch-client-js to 2.3.0
data/README.md CHANGED
@@ -103,6 +103,16 @@ class Contact < ActiveRecord::Base
103
103
  end
104
104
  ```
105
105
 
106
+ You can temporary disable auto-indexing using the <code>without_auto_index</code> scope. This is often used for performance reason.
107
+
108
+ ```ruby
109
+ Contact.delete_all
110
+ Contact.without_auto_index do
111
+ 1.upto(10000) { Contact.create! attributes } # inside the block, auto indexing task will noop
112
+ end
113
+ Contact.reindex! # will use batch operations
114
+ ```
115
+
106
116
  You can force indexing and removing to be synchronous by setting the following option:
107
117
 
108
118
  ```ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.5
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "algoliasearch-rails"
8
- s.version = "1.3.4"
8
+ s.version = "1.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Algolia"]
@@ -103,7 +103,17 @@ module AlgoliaSearch
103
103
  @options = { type: model_name, per_page: @index_options.get(:hitsPerPage) || 10, page: 1 }.merge(options)
104
104
  end
105
105
 
106
+ def without_auto_index(&block)
107
+ @without_auto_index_scope = true
108
+ begin
109
+ yield
110
+ ensure
111
+ @without_auto_index_scope = false
112
+ end
113
+ end
114
+
106
115
  def reindex!(batch_size = 1000, synchronous = false)
116
+ return if @without_auto_index_scope
107
117
  ensure_init
108
118
  last_task = nil
109
119
  find_in_batches(batch_size: batch_size) do |group|
@@ -114,6 +124,7 @@ module AlgoliaSearch
114
124
  end
115
125
 
116
126
  def index!(object, synchronous = false)
127
+ return if @without_auto_index_scope
117
128
  ensure_init
118
129
  if synchronous
119
130
  @index.add_object!(attributes(object), object.id.to_s)
@@ -123,6 +134,7 @@ module AlgoliaSearch
123
134
  end
124
135
 
125
136
  def remove_from_index!(object, synchronous = false)
137
+ return if @without_auto_index_scope
126
138
  ensure_init
127
139
  if synchronous
128
140
  @index.delete_object!(object.id.to_s)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia