meilisearch-rails 0.3.0 → 0.4.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: 9e05e5ed1e5210587bd2797412b0f5509b77151a620b79e4e8047c6c1722c3fb
4
- data.tar.gz: cfb5a6a39cf21caa0532ae40d005a8c7fd3fff30dbbfa02c90dd1f31f63259df
3
+ metadata.gz: e61a10b5b9eaf11606209ff295728cdd962acdb4f21d02004d416ed7346a3212
4
+ data.tar.gz: bd8b788affabaa81eafbcd027e223179c356e3d21af2083f335d2def1def71af
5
5
  SHA512:
6
- metadata.gz: 7a3e738a240fcbdc903d3a58acc9d5d68992a5e1adb56401fcd30a03e81c1fddbcc2024bed1338934de84d366ef58cc9e069243ad6ab5ca78c1330414e4a90b9
7
- data.tar.gz: 88228f931aafcbdd69fa483594c3842aaf7603dac277333107dc8629656e96f2fb0b0b57d84039b81b922f95cc9ef6322fb5745a4626058f135357779e227e0c
6
+ metadata.gz: 5e3af82f062f7578f8008c15050c67c1241b9922613e65dfeb8fb9c7ef6816e2900eb76b0836e726e3af0c408401761f6e9582ccd3ebd10173db49fc978b7015
7
+ data.tar.gz: '02424401493f9e983fa5b0b556e388191ef9612c7ab799cc781ed05bf8a42cb8a54cf98d3062bcd0c7525e81e0a986326fd37b89c853d83981bbf1332e0c9329'
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'json', '~> 2.5', '>= 2.5.1'
4
- gem 'meilisearch', '~> 0.17.0'
4
+ gem 'meilisearch', '~> 0.18.0'
5
5
 
6
6
  gem 'rubysl', '~> 2.0', platform: :rbx if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
7
7
 
@@ -28,7 +28,8 @@ group :test do
28
28
  gem 'activerecord-jdbc-adapter', platform: :jruby
29
29
  gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
30
30
  gem 'jdbc-sqlite3', platform: :jruby
31
- gem 'rspec', '>= 2.5.0', '< 3.0'
31
+ gem 'rspec', '~> 3.0'
32
+ gem 'simplecov', require: 'false'
32
33
 
33
34
  gem 'byebug'
34
35
  gem 'dotenv', '~> 2.7', '>= 2.7.6'
data/README.md CHANGED
@@ -58,7 +58,7 @@ To learn more about MeiliSearch, check out our [Documentation](https://docs.meil
58
58
 
59
59
  ## 🤖 Compatibility with MeiliSearch
60
60
 
61
- This package only guarantees the compatibility with the [version v0.24.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.24.0).
61
+ This package only guarantees the compatibility with the [version v0.25.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.25.0).
62
62
 
63
63
  ## 🔧 Installation <!-- omit in toc -->
64
64
 
@@ -659,7 +659,7 @@ class Book < ActiveRecord::Base
659
659
  end
660
660
  end
661
661
  ```
662
- 🚨 This is only recommended for testing purposes, the gem will call the `wait_for_pending_update` method that will stop your code execution until the asynchronous task has been processed by MeilSearch.
662
+ 🚨 This is only recommended for testing purposes, the gem will call the `wait_for_task` method that will stop your code execution until the asynchronous task has been processed by MeilSearch.
663
663
 
664
664
  ##### Disable auto-indexing & auto-removal <!-- omit in toc -->
665
665
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeiliSearch
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -129,7 +129,7 @@ module MeiliSearch
129
129
 
130
130
  def attributes_to_hash(attributes, document)
131
131
  if attributes
132
- attributes.map { |name, value| [name.to_s, value.call(document)] }.to_h
132
+ attributes.to_h { |name, value| [name.to_s, value.call(document)] }
133
133
  else
134
134
  {}
135
135
  end
@@ -237,7 +237,8 @@ module MeiliSearch
237
237
  def initialize(index_uid, raise_on_failure, options)
238
238
  client = MeiliSearch.client
239
239
  primary_key = options[:primary_key] || MeiliSearch::IndexSettings::DEFAULT_PRIMARY_KEY
240
- @index = client.get_or_create_index(index_uid, { primaryKey: primary_key })
240
+ client.create_index(index_uid, { primaryKey: primary_key })
241
+ @index = client.index(index_uid)
241
242
  @raise_on_failure = raise_on_failure.nil? || raise_on_failure
242
243
  end
243
244
 
@@ -254,12 +255,12 @@ module MeiliSearch
254
255
  end
255
256
  end
256
257
 
257
- # special handling of wait_for_pending_update to handle null task_id
258
- def wait_for_pending_update(update_id)
259
- return if update_id.nil? && !@raise_on_failure # ok
258
+ # special handling of wait_for_task to handle null task_id
259
+ def wait_for_task(task_uid)
260
+ return if task_uid.nil? && !@raise_on_failure # ok
260
261
 
261
- SafeIndex.log_or_throw(:wait_for_pending_update, @raise_on_failure) do
262
- @index.wait_for_pending_update(update_id)
262
+ SafeIndex.log_or_throw(:wait_for_task, @raise_on_failure) do
263
+ @index.wait_for_task(task_uid)
263
264
  end
264
265
  end
265
266
 
@@ -442,7 +443,7 @@ module MeiliSearch
442
443
  next if ms_indexing_disabled?(options)
443
444
 
444
445
  index = ms_ensure_init(options, settings)
445
- last_update = nil
446
+ last_task = nil
446
447
 
447
448
  ms_find_in_batches(batch_size) do |group|
448
449
  if ms_conditional_index?(options)
@@ -457,9 +458,9 @@ module MeiliSearch
457
458
  attributes = attributes.to_hash unless attributes.instance_of?(Hash)
458
459
  attributes.merge ms_pk(options) => ms_primary_key_of(d, options)
459
460
  end
460
- last_update= index.add_documents(documents)
461
+ last_task = index.add_documents(documents)
461
462
  end
462
- index.wait_for_pending_update(last_update['updateId']) if last_update && (synchronous || options[:synchronous])
463
+ index.wait_for_task(last_task['uid']) if last_task && (synchronous || options[:synchronous])
463
464
  end
464
465
  nil
465
466
  end
@@ -474,8 +475,8 @@ module MeiliSearch
474
475
  end
475
476
 
476
477
  index = SafeIndex.new(ms_index_uid(options), true, options)
477
- update = index.update_settings(final_settings)
478
- index.wait_for_pending_update(update['updateId']) if synchronous
478
+ task = index.update_settings(final_settings)
479
+ index.wait_for_task(task['uid']) if synchronous
479
480
  end
480
481
  end
481
482
 
@@ -484,8 +485,8 @@ module MeiliSearch
484
485
  next if ms_indexing_disabled?(options)
485
486
 
486
487
  index = ms_ensure_init(options, settings)
487
- update = index.add_documents(documents.map { |d| settings.get_attributes(d).merge ms_pk(options) => ms_primary_key_of(d, options) })
488
- index.wait_for_pending_update(update['updateId']) if synchronous || options[:synchronous]
488
+ task = index.add_documents(documents.map { |d| settings.get_attributes(d).merge ms_pk(options) => ms_primary_key_of(d, options) })
489
+ index.wait_for_task(task['uid']) if synchronous || options[:synchronous]
489
490
  end
490
491
  end
491
492
 
@@ -566,7 +567,7 @@ module MeiliSearch
566
567
  end
567
568
 
568
569
  index = ms_index(index_uid)
569
- index.search(q, params.map { |k, v| [k, v] }.to_h)
570
+ index.search(q, params.to_h { |k, v| [k, v] })
570
571
  end
571
572
 
572
573
  module AdditionalMethods
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meilisearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-18 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json