algoliasearch-rails 1.22.0 → 1.24.1

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: 04d14efb20e58715bff263a1eb160ccd0d192c7c44091b03aa2dc9f9ee9a3bac
4
- data.tar.gz: 0eaa9daddcdde5d578fa8a9657a3233bcf7b30d24af61f9892056c70bf9dfe3e
3
+ metadata.gz: 172aa1557bb7143640ef981eb9e392dbb6b719921b980d58f51d0deda1642710
4
+ data.tar.gz: 697a29f878ab2997b01ffd5cda494dacabe053dc802ceb183a13c8b1a488b4c2
5
5
  SHA512:
6
- metadata.gz: 10af848ac5cea8769630f6bbeab00756f85ba5dd27e17eedaa9f5a026c20c5d027ae60523ec42fa7e7c4a9d737995ee4b828a17a447ebf23fe9dc807760cf740
7
- data.tar.gz: 4427826729ef4ab92903e6161373b6eaee44b3601a236ce2278d1bda8d3f2351c06cffdd503d246ac965f5f75033dd058ef8622e5535d26ee7e75630c5ccccb8
6
+ metadata.gz: 35e400c2809ce5c39da5f1dbcd5f485692c483ae87668c6a2817e2d34bd0b24bde83973704e981567f58aeeb24cdd2bab814d97a86a3da6178ba12f270494b1c
7
+ data.tar.gz: d0d2277e45b06f564ba63daca91b5eadf4b78847af79f09b88ebc16e5fec4b85790b562e3cf9731b905417069ec3e5edeacf4787677041274de7d7a159bc5586
@@ -8,6 +8,7 @@ matrix:
8
8
  include:
9
9
  - rvm: 1.8.7
10
10
  env: RAILS_VERSION=3.2.0 SEQUEL_VERSION=4.0
11
+ dist: trusty
11
12
  - rvm: 1.9.3
12
13
  env: RAILS_VERSION=3.2.0
13
14
  - rvm: 1.9.3
@@ -34,6 +35,8 @@ matrix:
34
35
  env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
35
36
  - rvm: 2.6.0
36
37
  env: RAILS_VERSION=5.2 SEQUEL_VERSION=5.0
38
+ - rvm: 2.7.0
39
+ env: RAILS_VERSION=5.2 SEQUEL_VERSION=5.0
37
40
 
38
41
  before_install:
39
42
  - wget http://api-key-dealer.herokuapp.com/clients/algolia-keys && chmod +x algolia-keys
data/ChangeLog CHANGED
@@ -1,5 +1,55 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [1.24.1](https://github.com/algolia/algoliasearch-rails/releases/tag/1.24.1) (2020-07-15)
4
+
5
+ **Fixed**
6
+
7
+ * Fixes ruby warning 'Proc.new is deprecated'
8
+
9
+ ## [1.24.0](https://github.com/algolia/algoliasearch-rails/releases/tag/1.24.0) (2020-02-21)
10
+
11
+ **Added**
12
+
13
+ * Adds indexLanguages in index settings
14
+
15
+ ## [1.23.2](https://github.com/algolia/algoliasearch-rails/releases/tag/1.23.2) (2019-06-26)
16
+
17
+ **Fixed**
18
+
19
+ * Use `copy_index` when initiating a temporary index to preserve settings, synonyms, and rules.
20
+
21
+
22
+ ## [1.23.0](https://github.com/algolia/algoliasearch-rails/releases/tag/1.23.0) (2019-06-25)
23
+
24
+ **Added**
25
+
26
+ * Introduce `rake algoliasearch:set_all_settings` command - PR [#315](https://github.com/algolia/algoliasearch-rails/pull/315)
27
+
28
+ This command will push settings for all models to all indices: primary index,
29
+ replicas and additional indices. It follows the `inherit: true` option.
30
+ It should typically be added to your deployment script
31
+
32
+ * Add option to disable automatic settings - PR [#315](https://github.com/algolia/algoliasearch-rails/pull/315)
33
+
34
+ By default, this gem check your settings to see when to push them. Depending on
35
+ your implementation, it might create a lot of API calls. If you wish to disable
36
+ the automatic change detection for settings, use the `check_settings` option:
37
+
38
+ ```ruby
39
+ class Musician < ActiveRecord::Base
40
+ include AlgoliaSearch
41
+
42
+ algoliasearch check_settings: false do
43
+ # Settings...
44
+ end
45
+ end
46
+ ```
47
+
48
+ **Fixed**
49
+
50
+ * Handle attribute_changed? in transactions - PR [#354](https://github.com/algolia/algoliasearch-rails/pull/354)
51
+
52
+
3
53
  ## [1.22.0](https://github.com/algolia/algoliasearch-rails/releases/tag/1.22.0) (2019-03-21)
4
54
 
5
55
  🚨 The documentation for our Rails integration was refreshed 🎉
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'json', '~> 1.8', '>= 1.8.6'
4
- gem 'algoliasearch', '>= 1.17.0', '< 2.0.0'
4
+ gem 'algoliasearch', '>= 1.26.0', '< 2.0.0'
5
5
 
6
6
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
7
7
  gem 'rubysl', '~> 2.0', :platform => :rbx
@@ -1,72 +1,85 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actioncable (5.2.2)
5
- actionpack (= 5.2.2)
4
+ actioncable (6.0.1)
5
+ actionpack (= 6.0.1)
6
6
  nio4r (~> 2.0)
7
7
  websocket-driver (>= 0.6.1)
8
- actionmailer (5.2.2)
9
- actionpack (= 5.2.2)
10
- actionview (= 5.2.2)
11
- activejob (= 5.2.2)
8
+ actionmailbox (6.0.1)
9
+ actionpack (= 6.0.1)
10
+ activejob (= 6.0.1)
11
+ activerecord (= 6.0.1)
12
+ activestorage (= 6.0.1)
13
+ activesupport (= 6.0.1)
14
+ mail (>= 2.7.1)
15
+ actionmailer (6.0.1)
16
+ actionpack (= 6.0.1)
17
+ actionview (= 6.0.1)
18
+ activejob (= 6.0.1)
12
19
  mail (~> 2.5, >= 2.5.4)
13
20
  rails-dom-testing (~> 2.0)
14
- actionpack (5.2.2)
15
- actionview (= 5.2.2)
16
- activesupport (= 5.2.2)
21
+ actionpack (6.0.1)
22
+ actionview (= 6.0.1)
23
+ activesupport (= 6.0.1)
17
24
  rack (~> 2.0)
18
25
  rack-test (>= 0.6.3)
19
26
  rails-dom-testing (~> 2.0)
20
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
- actionview (5.2.2)
22
- activesupport (= 5.2.2)
27
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
28
+ actiontext (6.0.1)
29
+ actionpack (= 6.0.1)
30
+ activerecord (= 6.0.1)
31
+ activestorage (= 6.0.1)
32
+ activesupport (= 6.0.1)
33
+ nokogiri (>= 1.8.5)
34
+ actionview (6.0.1)
35
+ activesupport (= 6.0.1)
23
36
  builder (~> 3.1)
24
37
  erubi (~> 1.4)
25
38
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
27
- active_model_serializers (0.10.8)
28
- actionpack (>= 4.1, < 6)
29
- activemodel (>= 4.1, < 6)
39
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
40
+ active_model_serializers (0.10.10)
41
+ actionpack (>= 4.1, < 6.1)
42
+ activemodel (>= 4.1, < 6.1)
30
43
  case_transform (>= 0.2)
31
44
  jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
32
- activejob (5.2.2)
33
- activesupport (= 5.2.2)
45
+ activejob (6.0.1)
46
+ activesupport (= 6.0.1)
34
47
  globalid (>= 0.3.6)
35
- activemodel (5.2.2)
36
- activesupport (= 5.2.2)
37
- activerecord (5.2.2)
38
- activemodel (= 5.2.2)
39
- activesupport (= 5.2.2)
40
- arel (>= 9.0)
41
- activestorage (5.2.2)
42
- actionpack (= 5.2.2)
43
- activerecord (= 5.2.2)
48
+ activemodel (6.0.1)
49
+ activesupport (= 6.0.1)
50
+ activerecord (6.0.1)
51
+ activemodel (= 6.0.1)
52
+ activesupport (= 6.0.1)
53
+ activestorage (6.0.1)
54
+ actionpack (= 6.0.1)
55
+ activejob (= 6.0.1)
56
+ activerecord (= 6.0.1)
44
57
  marcel (~> 0.3.1)
45
- activesupport (5.2.2)
58
+ activesupport (6.0.1)
46
59
  concurrent-ruby (~> 1.0, >= 1.0.2)
47
60
  i18n (>= 0.7, < 2)
48
61
  minitest (~> 5.1)
49
62
  tzinfo (~> 1.1)
63
+ zeitwerk (~> 2.2)
50
64
  addressable (2.4.0)
51
- algoliasearch (1.25.2)
65
+ algoliasearch (1.27.1)
52
66
  httpclient (~> 2.8, >= 2.8.3)
53
67
  json (>= 1.5.1)
54
- arel (9.0.0)
55
- backports (3.11.4)
68
+ backports (3.15.0)
56
69
  builder (3.2.3)
57
70
  case_transform (0.2)
58
71
  activesupport
59
- concurrent-ruby (1.1.4)
60
- crass (1.0.4)
72
+ concurrent-ruby (1.1.5)
73
+ crass (1.0.5)
61
74
  diff-lcs (1.3)
62
- erubi (1.8.0)
63
- ethon (0.11.0)
75
+ erubi (1.9.0)
76
+ ethon (0.12.0)
64
77
  ffi (>= 1.3.0)
65
- faraday (0.15.4)
78
+ faraday (0.17.0)
66
79
  multipart-post (>= 1.2, < 3)
67
- faraday_middleware (0.12.2)
80
+ faraday_middleware (0.13.1)
68
81
  faraday (>= 0.7.4, < 1.0)
69
- ffi (1.9.25)
82
+ ffi (1.11.3)
70
83
  gh (0.15.1)
71
84
  addressable (~> 2.4.0)
72
85
  backports
@@ -74,14 +87,14 @@ GEM
74
87
  multi_json (~> 1.0)
75
88
  net-http-persistent (~> 2.9)
76
89
  net-http-pipeline
77
- globalid (0.4.1)
90
+ globalid (0.4.2)
78
91
  activesupport (>= 4.2.0)
79
92
  highline (1.7.10)
80
93
  httpclient (2.8.3)
81
- i18n (1.4.0)
94
+ i18n (1.7.0)
82
95
  concurrent-ruby (~> 1.0)
83
96
  json (1.8.6)
84
- jsonapi-renderer (0.2.0)
97
+ jsonapi-renderer (0.2.2)
85
98
  kaminari (1.1.1)
86
99
  activesupport (>= 4.1.0)
87
100
  kaminari-actionview (= 1.1.1)
@@ -96,7 +109,7 @@ GEM
96
109
  kaminari-core (1.1.1)
97
110
  launchy (2.4.3)
98
111
  addressable (~> 2.3)
99
- loofah (2.2.3)
112
+ loofah (2.4.0)
100
113
  crass (~> 1.0.2)
101
114
  nokogiri (>= 1.5.9)
102
115
  mail (2.7.1)
@@ -105,48 +118,50 @@ GEM
105
118
  mimemagic (~> 0.3.2)
106
119
  method_source (0.9.2)
107
120
  mimemagic (0.3.3)
108
- mini_mime (1.0.1)
121
+ mini_mime (1.0.2)
109
122
  mini_portile2 (2.4.0)
110
- minitest (5.11.3)
111
- multi_json (1.13.1)
112
- multipart-post (2.0.0)
123
+ minitest (5.13.0)
124
+ multi_json (1.14.1)
125
+ multipart-post (2.1.1)
113
126
  net-http-persistent (2.9.4)
114
127
  net-http-pipeline (1.0.1)
115
- nio4r (2.3.1)
116
- nokogiri (1.9.1)
128
+ nio4r (2.5.2)
129
+ nokogiri (1.10.5)
117
130
  mini_portile2 (~> 2.4.0)
118
131
  pusher-client (0.6.2)
119
132
  json
120
133
  websocket (~> 1.0)
121
- rack (2.0.6)
134
+ rack (2.0.7)
122
135
  rack-test (1.1.0)
123
136
  rack (>= 1.0, < 3)
124
- rails (5.2.2)
125
- actioncable (= 5.2.2)
126
- actionmailer (= 5.2.2)
127
- actionpack (= 5.2.2)
128
- actionview (= 5.2.2)
129
- activejob (= 5.2.2)
130
- activemodel (= 5.2.2)
131
- activerecord (= 5.2.2)
132
- activestorage (= 5.2.2)
133
- activesupport (= 5.2.2)
137
+ rails (6.0.1)
138
+ actioncable (= 6.0.1)
139
+ actionmailbox (= 6.0.1)
140
+ actionmailer (= 6.0.1)
141
+ actionpack (= 6.0.1)
142
+ actiontext (= 6.0.1)
143
+ actionview (= 6.0.1)
144
+ activejob (= 6.0.1)
145
+ activemodel (= 6.0.1)
146
+ activerecord (= 6.0.1)
147
+ activestorage (= 6.0.1)
148
+ activesupport (= 6.0.1)
134
149
  bundler (>= 1.3.0)
135
- railties (= 5.2.2)
150
+ railties (= 6.0.1)
136
151
  sprockets-rails (>= 2.0.0)
137
152
  rails-dom-testing (2.0.3)
138
153
  activesupport (>= 4.2.0)
139
154
  nokogiri (>= 1.6)
140
- rails-html-sanitizer (1.0.4)
141
- loofah (~> 2.2, >= 2.2.2)
142
- railties (5.2.2)
143
- actionpack (= 5.2.2)
144
- activesupport (= 5.2.2)
155
+ rails-html-sanitizer (1.3.0)
156
+ loofah (~> 2.3)
157
+ railties (6.0.1)
158
+ actionpack (= 6.0.1)
159
+ activesupport (= 6.0.1)
145
160
  method_source
146
161
  rake (>= 0.8.7)
147
- thor (>= 0.19.0, < 2.0)
162
+ thor (>= 0.20.3, < 2.0)
148
163
  rake (10.1.1)
149
- rdoc (6.1.1)
164
+ rdoc (6.2.0)
150
165
  redgreen (1.2.2)
151
166
  rspec (2.99.0)
152
167
  rspec-core (~> 2.99.0)
@@ -156,8 +171,8 @@ GEM
156
171
  rspec-expectations (2.99.2)
157
172
  diff-lcs (>= 1.1.3, < 2.0)
158
173
  rspec-mocks (2.99.4)
159
- sequel (5.16.0)
160
- sprockets (3.7.2)
174
+ sequel (5.26.0)
175
+ sprockets (4.0.0)
161
176
  concurrent-ruby (~> 1.0)
162
177
  rack (> 1, < 3)
163
178
  sprockets-rails (3.2.1)
@@ -167,7 +182,7 @@ GEM
167
182
  sqlite3 (1.3.13)
168
183
  thor (0.20.3)
169
184
  thread_safe (0.3.6)
170
- travis (1.8.9)
185
+ travis (1.8.10)
171
186
  backports
172
187
  faraday (~> 0.9)
173
188
  faraday_middleware (~> 0.9, >= 0.9.1)
@@ -181,10 +196,11 @@ GEM
181
196
  tzinfo (1.2.5)
182
197
  thread_safe (~> 0.1)
183
198
  websocket (1.2.8)
184
- websocket-driver (0.7.0)
199
+ websocket-driver (0.7.1)
185
200
  websocket-extensions (>= 0.1.0)
186
- websocket-extensions (0.1.3)
187
- will_paginate (3.1.6)
201
+ websocket-extensions (0.1.4)
202
+ will_paginate (3.2.1)
203
+ zeitwerk (2.2.1)
188
204
 
189
205
  PLATFORMS
190
206
  ruby
@@ -193,7 +209,7 @@ DEPENDENCIES
193
209
  active_model_serializers
194
210
  activerecord-jdbc-adapter
195
211
  activerecord-jdbcsqlite3-adapter
196
- algoliasearch (>= 1.17.0, < 2.0.0)
212
+ algoliasearch (>= 1.26.0, < 2.0.0)
197
213
  jdbc-sqlite3
198
214
  json (~> 1.8, >= 1.8.6)
199
215
  kaminari
@@ -208,4 +224,4 @@ DEPENDENCIES
208
224
  will_paginate (>= 2.3.15)
209
225
 
210
226
  BUNDLED WITH
211
- 1.17.3
227
+ 2.0.2
data/README.md CHANGED
@@ -1,9 +1,27 @@
1
-
2
- # Algolia Search API Client for Rails
3
-
4
- [Algolia Search](https://www.algolia.com) is a hosted search engine capable of delivering real-time results from the first keystroke.
5
-
6
- [![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.svg)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.svg)](https://codeclimate.com/github/algolia/algoliasearch-rails) ![ActiveRecord](https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square) ![Mongoid](https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square) ![Sequel](https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square)
1
+ <p align="center">
2
+ <a href="https://www.algolia.com">
3
+ <img alt="Algolia for Rails" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/rails.png" >
4
+ </a>
5
+
6
+ <h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your Rails project</h4>
7
+
8
+ <p align="center">
9
+ <a href="https://travis-ci.org/algolia/algoliasearch-rails"><img src="https://img.shields.io/travis/algolia/algoliasearch-rails/master.svg" alt="Build Status"></img></a>
10
+ <a href="http://badge.fury.io/rb/algoliasearch-rails"><img src="https://badge.fury.io/rb/algoliasearch-rails.svg" alt="Gem Version"></img></a>
11
+ <a href="https://codeclimate.com/github/algolia/algoliasearch-rails"><img src="https://codeclimate.com/github/algolia/algoliasearch-rails.svg" alt="Code Climate"></img></a>
12
+ <img src="https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square" alt="ActiveRecord"></img>
13
+ <img src="https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square" alt="Mongoid"></img>
14
+ <img src="https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square" alt="Sequel"></img>
15
+ </p>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="https://www.algolia.com/doc/framework-integration/rails/getting-started/setup/?language=ruby" target="_blank">Documentation</a> •
20
+ <a href="https://discourse.algolia.com" target="_blank">Community Forum</a> •
21
+ <a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a> •
22
+ <a href="https://github.com/algolia/algoliasearch-rails/issues" target="_blank">Report a bug</a> •
23
+ <a href="https://www.algolia.com/support" target="_blank">Support</a>
24
+ </p>
7
25
 
8
26
 
9
27
  This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem.
@@ -44,7 +62,7 @@ You can find the full reference on [Algolia's website](https://www.algolia.com/d
44
62
  * [Per-environment indices](#per-environment-indices)
45
63
  * [Custom attribute definition](#custom-attribute-definition)
46
64
  * [Nested objects/relations](#nested-objectsrelations)
47
- * [Custom <code>objectID</code>](#custom-codeobjectidcode)
65
+ * [Custom <code>objectID</code>](#custom-objectid)
48
66
  * [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
49
67
  * [Sanitizer](#sanitizer)
50
68
  * [UTF-8 Encoding](#utf-8-encoding)
@@ -142,7 +160,7 @@ class Contact < ActiveRecord::Base
142
160
  include AlgoliaSearch
143
161
 
144
162
  algoliasearch do
145
- attribute :first_name, :last_name, :email
163
+ attributes :first_name, :last_name, :email
146
164
  end
147
165
  end
148
166
  ```
@@ -79,7 +79,7 @@ Gem::Specification.new do |s|
79
79
 
80
80
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
81
  s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
82
- s.add_runtime_dependency(%q<algoliasearch>, [">= 1.17.0", "< 2.0.0"])
82
+ s.add_runtime_dependency(%q<algoliasearch>, [">= 1.26.0", "< 2.0.0"])
83
83
  s.add_development_dependency(%q<will_paginate>, [">= 2.3.15"])
84
84
  s.add_development_dependency(%q<kaminari>, [">= 0"])
85
85
  s.add_development_dependency "travis"
@@ -87,11 +87,11 @@ Gem::Specification.new do |s|
87
87
  s.add_development_dependency "rdoc"
88
88
  else
89
89
  s.add_dependency(%q<json>, [">= 1.5.1"])
90
- s.add_dependency(%q<algoliasearch>, [">= 1.17.0", "< 2.0.0"])
90
+ s.add_dependency(%q<algoliasearch>, [">= 1.26.0", "< 2.0.0"])
91
91
  end
92
92
  else
93
93
  s.add_dependency(%q<json>, [">= 1.5.1"])
94
- s.add_dependency(%q<algoliasearch>, [">= 1.17.0", "< 2.0.0"])
94
+ s.add_dependency(%q<algoliasearch>, [">= 1.26.0", "< 2.0.0"])
95
95
  end
96
96
  end
97
97
 
@@ -68,7 +68,7 @@ module AlgoliaSearch
68
68
  :disableTypoToleranceOnAttributes, :disableTypoToleranceOnWords, :separatorsToIndex,
69
69
  # Language
70
70
  :ignorePlurals, :removeStopWords, :camelCaseAttributes, :decompoundedAttributes,
71
- :keepDiacriticsOnCharacters, :queryLanguages,
71
+ :keepDiacriticsOnCharacters, :queryLanguages, :indexLanguages,
72
72
  # Query Rules
73
73
  :enableRules,
74
74
  # Query Strategy
@@ -90,9 +90,9 @@ module AlgoliaSearch
90
90
  end
91
91
  end
92
92
 
93
- def initialize(options, block)
93
+ def initialize(options, &block)
94
94
  @options = options
95
- instance_exec(&block) if block
95
+ instance_exec(&block) if block_given?
96
96
  end
97
97
 
98
98
  def use_serializer(serializer)
@@ -272,7 +272,7 @@ module AlgoliaSearch
272
272
  @additional_indexes ||= {}
273
273
  raise MixedSlavesAndReplicas.new('Cannot mix slaves and replicas in the same configuration (add_slave is deprecated)') if (options[:slave] && @additional_indexes.any? { |opts, _| opts[:replica] }) || (options[:replica] && @additional_indexes.any? { |opts, _| opts[:slave] })
274
274
  options[:index_name] = index_name
275
- @additional_indexes[options] = IndexSettings.new(options, Proc.new)
275
+ @additional_indexes[options] = IndexSettings.new(options, &block)
276
276
  end
277
277
 
278
278
  def add_replica(index_name, options = {}, &block)
@@ -389,7 +389,7 @@ module AlgoliaSearch
389
389
  end
390
390
 
391
391
  def algoliasearch(options = {}, &block)
392
- self.algoliasearch_settings = IndexSettings.new(options, block_given? ? Proc.new : nil)
392
+ self.algoliasearch_settings = IndexSettings.new(options, &block)
393
393
  self.algoliasearch_options = { :type => algolia_full_const_get(model_name.to_s), :per_page => algoliasearch_settings.get_setting(:hitsPerPage) || 10, :page => 1 }.merge(options)
394
394
 
395
395
  attr_accessor :highlight_result, :snippet_result
@@ -555,14 +555,21 @@ module AlgoliaSearch
555
555
  master_settings.delete 'replicas'
556
556
 
557
557
  # init temporary index
558
- index_name = algolia_index_name(options)
559
- tmp_options = options.merge({ :index_name => "#{index_name}.tmp" })
558
+ src_index_name = algolia_index_name(options)
559
+ tmp_index_name = "#{src_index_name}.tmp"
560
+ tmp_options = options.merge({ :index_name => tmp_index_name })
560
561
  tmp_options.delete(:per_environment) # already included in the temporary index_name
561
562
  tmp_settings = settings.dup
562
- tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
563
563
 
564
- algolia_find_in_batches(batch_size) do |group|
565
- if algolia_conditional_index?(tmp_options)
564
+ if options[:check_settings] == false
565
+ ::Algolia::copy_index!(src_index_name, tmp_index_name, %w(settings synonyms rules))
566
+ tmp_index = SafeIndex.new(tmp_index_name, !!options[:raise_on_failure])
567
+ else
568
+ tmp_index = algolia_ensure_init(tmp_options, tmp_settings, master_settings)
569
+ end
570
+
571
+ algolia_find_in_batches(batch_size) do |group|
572
+ if algolia_conditional_index?(options)
566
573
  # select only indexable objects
567
574
  group = group.select { |o| algolia_indexable?(o, tmp_options) }
568
575
  end
@@ -570,12 +577,31 @@ module AlgoliaSearch
570
577
  tmp_index.save_objects(objects)
571
578
  end
572
579
 
573
- move_task = SafeIndex.move_index(tmp_index.name, index_name)
580
+ move_task = SafeIndex.move_index(tmp_index.name, src_index_name)
574
581
  master_index.wait_task(move_task["taskID"]) if synchronous || options[:synchronous]
575
582
  end
576
583
  nil
577
584
  end
578
585
 
586
+ def algolia_set_settings(synchronous = false)
587
+ algolia_configurations.each do |options, settings|
588
+ if options[:primary_settings] && options[:inherit]
589
+ primary = options[:primary_settings].to_settings
590
+ primary.delete :slaves
591
+ primary.delete 'slaves'
592
+ primary.delete :replicas
593
+ primary.delete 'replicas'
594
+ final_settings = primary.merge(settings.to_settings)
595
+ else
596
+ final_settings = settings.to_settings
597
+ end
598
+
599
+ index = SafeIndex.new(algolia_index_name(options), true)
600
+ task = index.set_settings(final_settings)
601
+ index.wait_task(task["taskID"]) if synchronous
602
+ end
603
+ end
604
+
579
605
  def algolia_index_objects(objects, synchronous = false)
580
606
  algolia_configurations.each do |options, settings|
581
607
  next if algolia_indexing_disabled?(options)
@@ -743,6 +769,7 @@ module AlgoliaSearch
743
769
  return object.send(:algolia_dirty?) if (object.respond_to?(:algolia_dirty?))
744
770
  # Loop over each index to see if a attribute used in records has changed
745
771
  algolia_configurations.each do |options, settings|
772
+ next if algolia_indexing_disabled?(options)
746
773
  next if options[:slave] || options[:replica]
747
774
  return true if algolia_object_id_changed?(object, options)
748
775
  settings.get_attribute_names(object).each do |k|
@@ -785,7 +812,9 @@ module AlgoliaSearch
785
812
  index_settings ||= settings.to_settings
786
813
  index_settings = options[:primary_settings].to_settings.merge(index_settings) if options[:inherit]
787
814
 
788
- if !algolia_indexing_disabled?(options) && algoliasearch_settings_changed?(current_settings, index_settings)
815
+ options[:check_settings] = true if options[:check_settings].nil?
816
+
817
+ if !algolia_indexing_disabled?(options) && options[:check_settings] && algoliasearch_settings_changed?(current_settings, index_settings)
789
818
  used_slaves = !current_settings.nil? && !current_settings['slaves'].nil?
790
819
  replicas = index_settings.delete(:replicas) ||
791
820
  index_settings.delete('replicas') ||
@@ -952,8 +981,8 @@ module AlgoliaSearch
952
981
  return object.send("will_save_change_to_#{attr_name}?")
953
982
  end
954
983
 
955
- # Nil means we don't know if the attribute has changed
956
- nil
984
+ # We don't know if the attribute has changed, so conservatively assume it has
985
+ true
957
986
  end
958
987
 
959
988
  def automatic_changed_method?(object, method_name)
@@ -1017,7 +1046,9 @@ module AlgoliaSearch
1017
1046
  end
1018
1047
 
1019
1048
  def algolia_mark_must_reindex
1020
- @algolia_must_reindex =
1049
+ # algolia_must_reindex flag is reset after every commit as part. If we must reindex at any point in
1050
+ # a stransaction, keep flag set until it is explicitly unset
1051
+ @algolia_must_reindex ||=
1021
1052
  if defined?(::Sequel) && is_a?(Sequel::Model)
1022
1053
  new? || self.class.algolia_must_reindex?(self)
1023
1054
  else
@@ -5,7 +5,9 @@ module AlgoliaSearch
5
5
  end
6
6
 
7
7
  def configuration=(configuration)
8
- @@configuration = configuration.merge(:user_agent => "Algolia for Rails (#{AlgoliaSearch::VERSION}); Algolia for Ruby (#{Algolia::VERSION})")
8
+ @@configuration = configuration.merge(
9
+ :user_agent => "Algolia for Rails (#{AlgoliaSearch::VERSION}); Rails (#{Rails::VERSION::STRING})"
10
+ )
9
11
  Algolia.init @@configuration
10
12
  end
11
13
  end
@@ -1,9 +1,14 @@
1
1
  namespace :algoliasearch do
2
-
2
+
3
3
  desc "Reindex all models"
4
4
  task :reindex => :environment do
5
5
  AlgoliaSearch::Utilities.reindex_all_models
6
6
  end
7
+
8
+ desc "Set settings to all indexes"
9
+ task :set_all_settings => :environment do
10
+ AlgoliaSearch::Utilities.set_settings_all_models
11
+ end
7
12
 
8
13
  desc "Clear all indexes"
9
14
  task :clear_indexes => :environment do
@@ -25,6 +25,19 @@ module AlgoliaSearch
25
25
  klass.algolia_reindex
26
26
  end
27
27
  end
28
+
29
+ def set_settings_all_models
30
+ klasses = get_model_classes
31
+
32
+ puts ''
33
+ puts "Pushing settings for #{klasses.count} models: #{klasses.to_sentence}."
34
+ puts ''
35
+
36
+ klasses.each do |klass|
37
+ puts "Pushing #{klass} settings..."
38
+ klass.algolia_set_settings
39
+ end
40
+ end
28
41
  end
29
42
  end
30
43
  end
@@ -1,3 +1,3 @@
1
1
  module AlgoliaSearch
2
- VERSION = '1.22.0'
2
+ VERSION = '1.24.1'
3
3
  end
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.22.0
4
+ version: 1.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-21 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.17.0
33
+ version: 1.26.0
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: 2.0.0
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.17.0
43
+ version: 1.26.0
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: 2.0.0
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  requirements: []
191
- rubygems_version: 3.0.2
191
+ rubygems_version: 3.0.4
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: AlgoliaSearch integration to your favorite ORM