algoliasearch-rails 1.22.0 → 1.23.0

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: 6aa4976dffc097e623adfa3426845bceb29262940094082668defb70ecda498c
4
+ data.tar.gz: 72a7af5ba91d37dce26523a87562a2d571843d8322e19d7183153d677463d286
5
5
  SHA512:
6
- metadata.gz: 10af848ac5cea8769630f6bbeab00756f85ba5dd27e17eedaa9f5a026c20c5d027ae60523ec42fa7e7c4a9d737995ee4b828a17a447ebf23fe9dc807760cf740
7
- data.tar.gz: 4427826729ef4ab92903e6161373b6eaee44b3601a236ce2278d1bda8d3f2351c06cffdd503d246ac965f5f75033dd058ef8622e5535d26ee7e75630c5ccccb8
6
+ metadata.gz: c2b612ef3d142bd24aa7342f636fcb3659794611f51f413ac3e3586aca35954f5c3ae5f95481baa8fd091468caa9e2b5197bbf0d3529b1628a99fc1945519a0e
7
+ data.tar.gz: ec3ccc8b3589c89ddd3fada065304f087e47197ac876902969db526824ff38ea7335c3b37e4d6b32072c9251b5cf70d131559c2937c23ef414debf838c9161af
data/ChangeLog CHANGED
@@ -1,5 +1,36 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [1.23.0](https://github.com/algolia/algoliasearch-rails/releases/tag/1.23.0) (2019-06-25)
4
+
5
+ **Added**
6
+
7
+ * Introduce `rake algoliasearch:set_all_settings` command - PR [#315](https://github.com/algolia/algoliasearch-rails/pull/315)
8
+
9
+ This command will push settings for all models to all indices: primary index,
10
+ replicas and additional indices. It follows the `inherit: true` option.
11
+ It should typically be added to your deployment script
12
+
13
+ * Add option to disable automatic settings - PR [#315](https://github.com/algolia/algoliasearch-rails/pull/315)
14
+
15
+ By default, this gem check your settings to see when to push them. Depending on
16
+ your implementation, it might create a lot of API calls. If you wish to disable
17
+ the automatic change detection for settings, use the `check_settings` option:
18
+
19
+ ```ruby
20
+ class Musician < ActiveRecord::Base
21
+ include AlgoliaSearch
22
+
23
+ algoliasearch check_settings: false do
24
+ # Settings...
25
+ end
26
+ end
27
+ ```
28
+
29
+ **Fixed**
30
+
31
+ * Handle attribute_changed? in transactions - PR [#354](https://github.com/algolia/algoliasearch-rails/pull/354)
32
+
33
+
3
34
  ## [1.22.0](https://github.com/algolia/algoliasearch-rails/releases/tag/1.22.0) (2019-03-21)
4
35
 
5
36
  🚨 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.23.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,72 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actioncable (5.2.2)
5
- actionpack (= 5.2.2)
4
+ actioncable (5.2.3)
5
+ actionpack (= 5.2.3)
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
+ actionmailer (5.2.3)
9
+ actionpack (= 5.2.3)
10
+ actionview (= 5.2.3)
11
+ activejob (= 5.2.3)
12
12
  mail (~> 2.5, >= 2.5.4)
13
13
  rails-dom-testing (~> 2.0)
14
- actionpack (5.2.2)
15
- actionview (= 5.2.2)
16
- activesupport (= 5.2.2)
14
+ actionpack (5.2.3)
15
+ actionview (= 5.2.3)
16
+ activesupport (= 5.2.3)
17
17
  rack (~> 2.0)
18
18
  rack-test (>= 0.6.3)
19
19
  rails-dom-testing (~> 2.0)
20
20
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
21
- actionview (5.2.2)
22
- activesupport (= 5.2.2)
21
+ actionview (5.2.3)
22
+ activesupport (= 5.2.3)
23
23
  builder (~> 3.1)
24
24
  erubi (~> 1.4)
25
25
  rails-dom-testing (~> 2.0)
26
26
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
27
- active_model_serializers (0.10.8)
27
+ active_model_serializers (0.10.9)
28
28
  actionpack (>= 4.1, < 6)
29
29
  activemodel (>= 4.1, < 6)
30
30
  case_transform (>= 0.2)
31
31
  jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
32
- activejob (5.2.2)
33
- activesupport (= 5.2.2)
32
+ activejob (5.2.3)
33
+ activesupport (= 5.2.3)
34
34
  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)
35
+ activemodel (5.2.3)
36
+ activesupport (= 5.2.3)
37
+ activerecord (5.2.3)
38
+ activemodel (= 5.2.3)
39
+ activesupport (= 5.2.3)
40
40
  arel (>= 9.0)
41
- activestorage (5.2.2)
42
- actionpack (= 5.2.2)
43
- activerecord (= 5.2.2)
41
+ activestorage (5.2.3)
42
+ actionpack (= 5.2.3)
43
+ activerecord (= 5.2.3)
44
44
  marcel (~> 0.3.1)
45
- activesupport (5.2.2)
45
+ activesupport (5.2.3)
46
46
  concurrent-ruby (~> 1.0, >= 1.0.2)
47
47
  i18n (>= 0.7, < 2)
48
48
  minitest (~> 5.1)
49
49
  tzinfo (~> 1.1)
50
50
  addressable (2.4.0)
51
- algoliasearch (1.25.2)
51
+ algoliasearch (1.26.0)
52
52
  httpclient (~> 2.8, >= 2.8.3)
53
53
  json (>= 1.5.1)
54
54
  arel (9.0.0)
55
- backports (3.11.4)
55
+ backports (3.15.0)
56
56
  builder (3.2.3)
57
57
  case_transform (0.2)
58
58
  activesupport
59
- concurrent-ruby (1.1.4)
59
+ concurrent-ruby (1.1.5)
60
60
  crass (1.0.4)
61
61
  diff-lcs (1.3)
62
62
  erubi (1.8.0)
63
- ethon (0.11.0)
63
+ ethon (0.12.0)
64
64
  ffi (>= 1.3.0)
65
65
  faraday (0.15.4)
66
66
  multipart-post (>= 1.2, < 3)
67
- faraday_middleware (0.12.2)
67
+ faraday_middleware (0.13.1)
68
68
  faraday (>= 0.7.4, < 1.0)
69
- ffi (1.9.25)
69
+ ffi (1.11.1)
70
70
  gh (0.15.1)
71
71
  addressable (~> 2.4.0)
72
72
  backports
@@ -74,14 +74,14 @@ GEM
74
74
  multi_json (~> 1.0)
75
75
  net-http-persistent (~> 2.9)
76
76
  net-http-pipeline
77
- globalid (0.4.1)
77
+ globalid (0.4.2)
78
78
  activesupport (>= 4.2.0)
79
79
  highline (1.7.10)
80
80
  httpclient (2.8.3)
81
- i18n (1.4.0)
81
+ i18n (1.6.0)
82
82
  concurrent-ruby (~> 1.0)
83
83
  json (1.8.6)
84
- jsonapi-renderer (0.2.0)
84
+ jsonapi-renderer (0.2.2)
85
85
  kaminari (1.1.1)
86
86
  activesupport (>= 4.1.0)
87
87
  kaminari-actionview (= 1.1.1)
@@ -109,39 +109,39 @@ GEM
109
109
  mini_portile2 (2.4.0)
110
110
  minitest (5.11.3)
111
111
  multi_json (1.13.1)
112
- multipart-post (2.0.0)
112
+ multipart-post (2.1.1)
113
113
  net-http-persistent (2.9.4)
114
114
  net-http-pipeline (1.0.1)
115
115
  nio4r (2.3.1)
116
- nokogiri (1.9.1)
116
+ nokogiri (1.10.3)
117
117
  mini_portile2 (~> 2.4.0)
118
118
  pusher-client (0.6.2)
119
119
  json
120
120
  websocket (~> 1.0)
121
- rack (2.0.6)
121
+ rack (2.0.7)
122
122
  rack-test (1.1.0)
123
123
  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)
124
+ rails (5.2.3)
125
+ actioncable (= 5.2.3)
126
+ actionmailer (= 5.2.3)
127
+ actionpack (= 5.2.3)
128
+ actionview (= 5.2.3)
129
+ activejob (= 5.2.3)
130
+ activemodel (= 5.2.3)
131
+ activerecord (= 5.2.3)
132
+ activestorage (= 5.2.3)
133
+ activesupport (= 5.2.3)
134
134
  bundler (>= 1.3.0)
135
- railties (= 5.2.2)
135
+ railties (= 5.2.3)
136
136
  sprockets-rails (>= 2.0.0)
137
137
  rails-dom-testing (2.0.3)
138
138
  activesupport (>= 4.2.0)
139
139
  nokogiri (>= 1.6)
140
140
  rails-html-sanitizer (1.0.4)
141
141
  loofah (~> 2.2, >= 2.2.2)
142
- railties (5.2.2)
143
- actionpack (= 5.2.2)
144
- activesupport (= 5.2.2)
142
+ railties (5.2.3)
143
+ actionpack (= 5.2.3)
144
+ activesupport (= 5.2.3)
145
145
  method_source
146
146
  rake (>= 0.8.7)
147
147
  thor (>= 0.19.0, < 2.0)
@@ -156,7 +156,7 @@ GEM
156
156
  rspec-expectations (2.99.2)
157
157
  diff-lcs (>= 1.1.3, < 2.0)
158
158
  rspec-mocks (2.99.4)
159
- sequel (5.16.0)
159
+ sequel (5.21.0)
160
160
  sprockets (3.7.2)
161
161
  concurrent-ruby (~> 1.0)
162
162
  rack (> 1, < 3)
@@ -167,7 +167,7 @@ GEM
167
167
  sqlite3 (1.3.13)
168
168
  thor (0.20.3)
169
169
  thread_safe (0.3.6)
170
- travis (1.8.9)
170
+ travis (1.8.10)
171
171
  backports
172
172
  faraday (~> 0.9)
173
173
  faraday_middleware (~> 0.9, >= 0.9.1)
@@ -181,10 +181,10 @@ GEM
181
181
  tzinfo (1.2.5)
182
182
  thread_safe (~> 0.1)
183
183
  websocket (1.2.8)
184
- websocket-driver (0.7.0)
184
+ websocket-driver (0.7.1)
185
185
  websocket-extensions (>= 0.1.0)
186
- websocket-extensions (0.1.3)
187
- will_paginate (3.1.6)
186
+ websocket-extensions (0.1.4)
187
+ will_paginate (3.1.7)
188
188
 
189
189
  PLATFORMS
190
190
  ruby
@@ -208,4 +208,4 @@ DEPENDENCIES
208
208
  will_paginate (>= 2.3.15)
209
209
 
210
210
  BUNDLED WITH
211
- 1.17.3
211
+ 2.0.1
data/README.md CHANGED
@@ -44,7 +44,7 @@ You can find the full reference on [Algolia's website](https://www.algolia.com/d
44
44
  * [Per-environment indices](#per-environment-indices)
45
45
  * [Custom attribute definition](#custom-attribute-definition)
46
46
  * [Nested objects/relations](#nested-objectsrelations)
47
- * [Custom <code>objectID</code>](#custom-codeobjectidcode)
47
+ * [Custom <code>objectID</code>](#custom-objectid)
48
48
  * [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
49
49
  * [Sanitizer](#sanitizer)
50
50
  * [UTF-8 Encoding](#utf-8-encoding)
@@ -576,6 +576,25 @@ module AlgoliaSearch
576
576
  nil
577
577
  end
578
578
 
579
+ def algolia_set_settings(synchronous = false)
580
+ algolia_configurations.each do |options, settings|
581
+ if options[:primary_settings] && options[:inherit]
582
+ primary = options[:primary_settings].to_settings
583
+ primary.delete :slaves
584
+ primary.delete 'slaves'
585
+ primary.delete :replicas
586
+ primary.delete 'replicas'
587
+ final_settings = primary.merge(settings.to_settings)
588
+ else
589
+ final_settings = settings.to_settings
590
+ end
591
+
592
+ index = SafeIndex.new(algolia_index_name(options), true)
593
+ task = index.set_settings(final_settings)
594
+ index.wait_task(task["taskID"]) if synchronous
595
+ end
596
+ end
597
+
579
598
  def algolia_index_objects(objects, synchronous = false)
580
599
  algolia_configurations.each do |options, settings|
581
600
  next if algolia_indexing_disabled?(options)
@@ -743,6 +762,7 @@ module AlgoliaSearch
743
762
  return object.send(:algolia_dirty?) if (object.respond_to?(:algolia_dirty?))
744
763
  # Loop over each index to see if a attribute used in records has changed
745
764
  algolia_configurations.each do |options, settings|
765
+ next if algolia_indexing_disabled?(options)
746
766
  next if options[:slave] || options[:replica]
747
767
  return true if algolia_object_id_changed?(object, options)
748
768
  settings.get_attribute_names(object).each do |k|
@@ -785,7 +805,9 @@ module AlgoliaSearch
785
805
  index_settings ||= settings.to_settings
786
806
  index_settings = options[:primary_settings].to_settings.merge(index_settings) if options[:inherit]
787
807
 
788
- if !algolia_indexing_disabled?(options) && algoliasearch_settings_changed?(current_settings, index_settings)
808
+ options[:check_settings] = true if options[:check_settings].nil?
809
+
810
+ if !algolia_indexing_disabled?(options) && options[:check_settings] && algoliasearch_settings_changed?(current_settings, index_settings)
789
811
  used_slaves = !current_settings.nil? && !current_settings['slaves'].nil?
790
812
  replicas = index_settings.delete(:replicas) ||
791
813
  index_settings.delete('replicas') ||
@@ -952,8 +974,8 @@ module AlgoliaSearch
952
974
  return object.send("will_save_change_to_#{attr_name}?")
953
975
  end
954
976
 
955
- # Nil means we don't know if the attribute has changed
956
- nil
977
+ # We don't know if the attribute has changed, so conservatively assume it has
978
+ true
957
979
  end
958
980
 
959
981
  def automatic_changed_method?(object, method_name)
@@ -1017,7 +1039,9 @@ module AlgoliaSearch
1017
1039
  end
1018
1040
 
1019
1041
  def algolia_mark_must_reindex
1020
- @algolia_must_reindex =
1042
+ # algolia_must_reindex flag is reset after every commit as part. If we must reindex at any point in
1043
+ # a stransaction, keep flag set until it is explicitly unset
1044
+ @algolia_must_reindex ||=
1021
1045
  if defined?(::Sequel) && is_a?(Sequel::Model)
1022
1046
  new? || self.class.algolia_must_reindex?(self)
1023
1047
  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})"
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.23.0'
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.23.0
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: 2019-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -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.3
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: AlgoliaSearch integration to your favorite ORM