algoliasearch-rails 1.2.1 → 1.3.0

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: 488ab2486b67c8317deadff4c549f647794104c6
4
- data.tar.gz: 74d5cf101bf372f2a3f5fafadd9aa33fe453d5e6
3
+ metadata.gz: 870048b483ecc405daa61ebd24ef2624adeb48d0
4
+ data.tar.gz: daef90a5174d5424debf92a2301ea82a39a3d92f
5
5
  SHA512:
6
- metadata.gz: f48a72b377a901ce37da8be9e3f2789d2e70c5913ef434d2f8ebea46d37d4e870e6284e6fdf510271ee8445055d20b41a66777518617a5000687b73fb8004c58
7
- data.tar.gz: 0f232facf4c9bb579fa9a93ccfa60733a443c4b0c5b4680bd73681f4f46682c1912d21286e3d63e9ad5102a06f51d3384dfecff303c531bfd20db3e634a53fd7
6
+ metadata.gz: 9a72f0cab95ce45d1ab1a348c659944ce955a5738a6d48b3e3cc8fcfce7ba46e339e6a9ccfea0b582a10fe931b971780da0e0c8bad4c1229a8255238e57ec3ce
7
+ data.tar.gz: 08221737fd46c48e13a447e21270606ab3e18fa8fcb468d7bfdd60e48b5f55d646bbf12d63dc2d71f004149d6c556e93d768f4f8a6a40989472bafc834900fca
@@ -0,0 +1,31 @@
1
+ CHANGELOG
2
+
3
+ 2013-10-15 1.3.0
4
+
5
+ * synchronous flag is now false by default
6
+ * do not set settings if they didn't chang
7
+
8
+ 2013-10-15 1.2.1
9
+
10
+ * Updated deps, especially algoliasearch to 1.1.3 to solve thread-safety issues
11
+
12
+ 2013-10-14 1.2.0
13
+
14
+ * embeds a typeahead.js based UI
15
+
16
+ 2013-10-04 1.1.8
17
+
18
+ * Avoid concurrent access to the same index while running tests with TravisCI
19
+ * to check if the full-reindexing has been done, checking the last task is enough
20
+
21
+ 2013-10-02 1.1.7
22
+
23
+ * Updated environment variables
24
+ * Plug travis and various badges
25
+ * Fixed attribute changes detection
26
+ * Upgrade to algoliasearch-client-ruby 1.1.1
27
+
28
+ 2013-10-01 1.1.6
29
+
30
+ * Initial import
31
+
data/README.md CHANGED
@@ -87,7 +87,7 @@ p Contact.search("jon doe")
87
87
  Options
88
88
  ----------
89
89
 
90
- Each time a record is saved; it will be - synchronously - indexed. In the other hand, each time a record is destroyed, it will be - synchronoulsy - removed from the index.
90
+ Each time a record is saved; it will be - asynchronously - indexed. In the other hand, each time a record is destroyed, it will be - asynchronoulsy - removed from the index.
91
91
 
92
92
  You can disable auto-indexing and auto-removing setting the following options:
93
93
 
@@ -101,13 +101,13 @@ class Contact < ActiveRecord::Base
101
101
  end
102
102
  ```
103
103
 
104
- You can force indexing and removing to be asynchronous by setting the following option:
104
+ You can force indexing and removing to be synchronous by setting the following option:
105
105
 
106
106
  ```ruby
107
107
  class Contact < ActiveRecord::Base
108
108
  include AlgoliaSearch
109
109
 
110
- algoliasearch synchronous: false do
110
+ algoliasearch synchronous: true do
111
111
  attribute :first_name, :last_name, :email
112
112
  end
113
113
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.3.0
@@ -5,14 +5,15 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "algoliasearch-rails"
8
- s.version = "1.2.1"
8
+ s.version = "1.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Algolia"]
12
- s.date = "2013-10-15"
12
+ s.date = "2013-10-16"
13
13
  s.description = "AlgoliaSearch integration to your favorite ORM"
14
14
  s.email = "contact@algolia.com"
15
15
  s.extra_rdoc_files = [
16
+ "ChangeLog",
16
17
  "LICENSE",
17
18
  "README.md"
18
19
  ]
@@ -20,6 +21,7 @@ Gem::Specification.new do |s|
20
21
  ".document",
21
22
  ".rspec",
22
23
  ".travis.yml",
24
+ "ChangeLog",
23
25
  "Gemfile",
24
26
  "Gemfile.lock",
25
27
  "LICENSE",
@@ -87,7 +87,7 @@ module AlgoliaSearch
87
87
  @index_options = IndexOptions.new(block_given? ? Proc.new : nil)
88
88
  attr_accessor :highlight_result
89
89
 
90
- unless options[:synchronous] == false
90
+ if options[:synchronous] == true
91
91
  before_save :mark_synchronous if respond_to?(:before_save)
92
92
  end
93
93
  unless options[:auto_index] == false
@@ -103,7 +103,7 @@ module AlgoliaSearch
103
103
  init
104
104
  end
105
105
 
106
- def reindex!(batch_size = 1000, synchronous = true)
106
+ def reindex!(batch_size = 1000, synchronous = false)
107
107
  last_task = nil
108
108
  find_in_batches(batch_size: batch_size) do |group|
109
109
  objects = group.map { |o| attributes(o).merge 'objectID' => o.id.to_s }
@@ -112,7 +112,7 @@ module AlgoliaSearch
112
112
  @index.wait_task(last_task["taskID"]) if last_task and synchronous == true
113
113
  end
114
114
 
115
- def index!(object, synchronous = true)
115
+ def index!(object, synchronous = false)
116
116
  if synchronous
117
117
  @index.add_object!(attributes(object), object.id.to_s)
118
118
  else
@@ -120,7 +120,7 @@ module AlgoliaSearch
120
120
  end
121
121
  end
122
122
 
123
- def remove_from_index!(object, synchronous = true)
123
+ def remove_from_index!(object, synchronous = false)
124
124
  if synchronous
125
125
  @index.delete_object!(object.id.to_s)
126
126
  else
@@ -147,7 +147,8 @@ module AlgoliaSearch
147
147
  def init
148
148
  @index ||= Algolia::Index.new(@options[:index_name] || model_name)
149
149
  settings = @index_options.to_settings
150
- @index.set_settings(settings) if !settings.empty?
150
+ prev_settings = @index.get_settings rescue nil # if the index doesn't exist
151
+ @index.set_settings(settings) if index_settings_changed?(prev_settings, settings)
151
152
  end
152
153
 
153
154
  def must_reindex?(object)
@@ -166,6 +167,14 @@ module AlgoliaSearch
166
167
  Hash[@index_options.attributes.map { |attr| [attr.to_s, object.send(attr)] }]
167
168
  end
168
169
 
170
+ def index_settings_changed?(prev, current)
171
+ return true if prev.nil?
172
+ current.each do |k, v|
173
+ return true if prev[k.to_s] != v
174
+ end
175
+ false
176
+ end
177
+
169
178
  end
170
179
 
171
180
  # these are the instance methods included
@@ -181,7 +190,7 @@ module AlgoliaSearch
181
190
  private
182
191
 
183
192
  def synchronous?
184
- @synchronous.nil? || @synchronous == true
193
+ @synchronous == true
185
194
  end
186
195
 
187
196
  def mark_synchronous
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.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -99,12 +99,14 @@ email: contact@algolia.com
99
99
  executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files:
102
+ - ChangeLog
102
103
  - LICENSE
103
104
  - README.md
104
105
  files:
105
106
  - .document
106
107
  - .rspec
107
108
  - .travis.yml
109
+ - ChangeLog
108
110
  - Gemfile
109
111
  - Gemfile.lock
110
112
  - LICENSE