meilisearch-rails 0.14.0 → 0.14.2

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: ba5387112e0280c13ed074d356fdaa706c14a933d0a2ae540f16ecad75829db3
4
- data.tar.gz: 04560a2a843b527439d02abddf63d23ab218860e06fa6005ca4d5cc2cdf939cc
3
+ metadata.gz: dab897ac0b83c33721dc40eab5be2d2cc5013c14380a1d47df590f44339433fc
4
+ data.tar.gz: d99e1fd1970915a665a328233df77bf526f0510478fa2087b502a6224e8a2635
5
5
  SHA512:
6
- metadata.gz: 8e3ca9d2407f083234b5a925ed31285d67d705c7e97ac07840989061a75ae6fbc9cdbf6e2f179d40f13d7b5751967727caaf872ae1d8b80a39494e6732692155
7
- data.tar.gz: 2d97cf8dee950fb9d9afe58b78eac6e4df2131eb0864a4a5b44bd247e97f79b759a66f6cf1882da37d7dca3a03b909ff5aacc71bd8063bf04e27ccf9b8dd4871
6
+ metadata.gz: 67e71e231498dd94223096fd3bb02a7f79a8861a4a013f3a628ee3141db3436e323df1cd671caeb20937fe39533c558bd540c4eceae6f6b69713a3af8ceb1a93
7
+ data.tar.gz: 23ac15e8d4d42a1af5d9f2c38e84b9e7c810979af2ca8264eb818b80aaaf84d2ad973512857f2c40c0708dee82a6d67ddc2097e542cc71c4e64f7bc1cb72edbe
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -13,17 +13,18 @@ group :development do
13
13
  end
14
14
 
15
15
  group :test do
16
- rails_version = ENV['RAILS_VERSION'] || '6.1'
16
+ rails_version = ENV['RAILS_VERSION'] || '7.1'
17
17
  sequel_version = ENV['SEQUEL_VERSION'] ? "~> #{ENV['SEQUEL_VERSION']}" : '>= 4.0'
18
18
 
19
19
  gem 'active_model_serializers'
20
20
  gem 'rails', "~> #{rails_version}"
21
21
  gem 'sequel', sequel_version
22
22
 
23
- if Gem::Version.new(rails_version) >= Gem::Version.new('6.0')
24
- gem 'sqlite3', '~> 1.4.0', platform: %i[rbx ruby]
23
+ # remove when deprecate rails 6
24
+ if Gem::Version.new(rails_version) >= Gem::Version.new('7.0')
25
+ gem 'sqlite3', '~> 2', platform: %i[rbx ruby]
25
26
  else
26
- gem 'sqlite3', '< 1.4.0', platform: %i[rbx ruby]
27
+ gem 'sqlite3', '< 2', platform: %i[rbx ruby]
27
28
  end
28
29
 
29
30
  gem 'activerecord-jdbc-adapter', platform: :jruby
@@ -33,6 +34,7 @@ group :test do
33
34
  gem 'simplecov', require: 'false'
34
35
  gem 'simplecov-cobertura', require: 'false'
35
36
  gem 'threads'
37
+ gem 'logger'
36
38
 
37
39
  gem 'byebug'
38
40
  gem 'dotenv', '~> 2.7', '>= 2.7.6'
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2024 Meili SAS
3
+ Copyright (c) 2021-2025 Meili SAS
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -32,7 +32,6 @@
32
32
  ## Table of Contents <!-- omit in TOC -->
33
33
 
34
34
  - [📖 Documentation](#-documentation)
35
- - [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
36
35
  - [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
37
36
  - [🚀 Getting started](#-getting-started)
38
37
  - [Compatibility](#-compatibility)
@@ -66,10 +65,6 @@ The whole usage of this gem is detailed in this README.
66
65
 
67
66
  To learn more about Meilisearch, check out our [Documentation](https://www.meilisearch.com/docs/learn/tutorials/getting_started.html) or our [API References](https://www.meilisearch.com/docs/reference/api/).
68
67
 
69
- ## ⚡ Supercharge your Meilisearch experience
70
-
71
- Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/pricing?utm_campaign=oss&utm_source=integration&utm_medium=meilisearch-rails). No credit card required.
72
-
73
68
  ## 🤖 Compatibility with Meilisearch
74
69
 
75
70
  This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-rails/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.
@@ -92,16 +87,9 @@ gem 'meilisearch-rails'
92
87
 
93
88
  ### Run Meilisearch <!-- omit in toc -->
94
89
 
95
- There are many easy ways to [download and run a Meilisearch instance](https://www.meilisearch.com/docs/reference/features/installation.html#download-and-launch).
96
-
97
- For example, if you use Docker:
98
-
99
- ```bash
100
- docker pull getmeili/meilisearch:latest # Fetch the latest version of Meilisearch image from Docker Hub
101
- docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey
102
- ```
90
+ ⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-rails).
103
91
 
104
- NB: you can also download Meilisearch from **Homebrew** or **APT**.
92
+ 🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-rails) our fast, open-source search engine on your own infrastructure.
105
93
 
106
94
  ## 🚀 Getting started
107
95
 
@@ -8,7 +8,7 @@ module MeiliSearch
8
8
  index = MeiliSearch::Rails.client.index(document[:index_uid])
9
9
 
10
10
  if document[:synchronous]
11
- index.delete_document!(document[:primary_key])
11
+ index.delete_document(document[:primary_key]).await
12
12
  else
13
13
  index.delete_document(document[:primary_key])
14
14
  end
@@ -19,13 +19,16 @@ module MeiliSearch
19
19
 
20
20
  def self.create(results, total_hits, options = {})
21
21
  offset = ((options[:page] - 1) * options[:per_page])
22
- array = new results, limit: options[:per_page], offset: offset, total_count: total_hits
22
+ total_hits = 0 if total_hits.nil?
23
+ offset = 0 if offset.nil?
24
+ limit = 0 if options[:per_page].nil?
25
+ array = new results, limit: limit, offset: offset, total_count: total_hits
23
26
 
24
27
  if array.empty? && !results.empty?
25
28
  # since Kaminari 0.16.0, you need to pad the results with nil values so it matches the offset param
26
29
  # otherwise you'll get an empty array: https://github.com/amatsuda/kaminari/commit/29fdcfa8865f2021f710adaedb41b7a7b081e34d
27
30
  results = Array.new(offset) + results
28
- array = new results, offset: offset, limit: options[:per_page], total_count: total_hits
31
+ array = new results, offset: offset, limit: limit, total_count: total_hits
29
32
  end
30
33
 
31
34
  array
@@ -2,7 +2,7 @@
2
2
 
3
3
  module MeiliSearch
4
4
  module Rails
5
- VERSION = '0.14.0'
5
+ VERSION = '0.14.2'
6
6
 
7
7
  def self.qualified_version
8
8
  "Meilisearch Rails (v#{VERSION})"
@@ -84,6 +84,22 @@ module MeiliSearch
84
84
  def initialize(options, &block)
85
85
  @options = options
86
86
  instance_exec(&block) if block_given?
87
+ warn_searchable_missing_attributes
88
+ end
89
+
90
+ def warn_searchable_missing_attributes
91
+ searchables = get_setting(:searchable_attributes)&.map { |searchable| searchable.to_s.split('.').first }
92
+ attrs = get_setting(:attributes)&.map { |k, _| k.to_s }
93
+
94
+ if searchables.present? && attrs.present?
95
+ (searchables - attrs).each do |missing_searchable|
96
+ warning = <<~WARNING
97
+ [meilisearch-rails] #{missing_searchable} declared in searchable_attributes but not in attributes. \
98
+ Please add it to attributes if it should be searchable.
99
+ WARNING
100
+ MeiliSearch::Rails.logger.warn(warning)
101
+ end
102
+ end
87
103
  end
88
104
 
89
105
  def use_serializer(serializer)
@@ -464,8 +480,6 @@ module MeiliSearch
464
480
  after_destroy_commit { |searchable| searchable.ms_enqueue_remove_from_index!(ms_synchronous?) }
465
481
  end
466
482
  end
467
-
468
- warn_searchable_missing_attributes
469
483
  end
470
484
 
471
485
  def ms_without_auto_index(&block)
@@ -555,14 +569,14 @@ module MeiliSearch
555
569
  doc = doc.merge ms_pk(options) => primary_key
556
570
 
557
571
  if synchronous || options[:synchronous]
558
- index.add_documents!(doc)
572
+ index.add_documents(doc).await
559
573
  else
560
574
  index.add_documents(doc)
561
575
  end
562
576
  elsif ms_conditional_index?(options) && primary_key.present?
563
577
  # remove non-indexable documents
564
578
  if synchronous || options[:synchronous]
565
- index.delete_document!(primary_key)
579
+ index.delete_document(primary_key).await
566
580
  else
567
581
  index.delete_document(primary_key)
568
582
  end
@@ -594,7 +608,7 @@ module MeiliSearch
594
608
 
595
609
  index = ms_ensure_init(options, settings)
596
610
  if synchronous || options[:synchronous]
597
- index.delete_document!(primary_key)
611
+ index.delete_document(primary_key).await
598
612
  else
599
613
  index.delete_document(primary_key)
600
614
  end
@@ -607,7 +621,7 @@ module MeiliSearch
607
621
  next if ms_indexing_disabled?(options)
608
622
 
609
623
  index = ms_ensure_init(options, settings)
610
- synchronous || options[:synchronous] ? index.delete_all_documents! : index.delete_all_documents
624
+ synchronous || options[:synchronous] ? index.delete_all_documents.await : index.delete_all_documents
611
625
  @ms_indexes[MeiliSearch::Rails.active?][settings] = nil
612
626
  end
613
627
  nil
@@ -901,19 +915,6 @@ module MeiliSearch
901
915
  # We don't know if the attribute has changed, so conservatively assume it has
902
916
  true
903
917
  end
904
-
905
- def warn_searchable_missing_attributes
906
- searchables = meilisearch_settings.get_setting(:searchable_attributes)
907
- attrs = meilisearch_settings.get_setting(:attributes)&.keys
908
-
909
- if searchables.present? && attrs.present?
910
- (searchables.map(&:to_s) - attrs.map(&:to_s)).each do |missing_searchable|
911
- MeiliSearch::Rails.logger.warn(
912
- "[meilisearch-rails] #{name}##{missing_searchable} declared in searchable_attributes but not in attributes. Please add it to attributes if it should be searchable."
913
- )
914
- end
915
- end
916
- end
917
918
  end
918
919
 
919
920
  # these are the instance methods included
@@ -34,5 +34,6 @@ Gem::Specification.new do |s|
34
34
 
35
35
  s.required_ruby_version = '>= 3.0.0'
36
36
 
37
- s.add_dependency 'meilisearch', '~> 0.28'
37
+ s.add_dependency 'meilisearch', '~> 0.28.4'
38
+ s.add_dependency 'mutex_m', '~> 0.2'
38
39
  end
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.14.0
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
11
+ date: 2025-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: meilisearch
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.28'
19
+ version: 0.28.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.28'
26
+ version: 0.28.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: mutex_m
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
27
41
  description: Meilisearch integration for Ruby on Rails. See https://github.com/meilisearch/meilisearch
28
42
  email: bonjour@meilisearch.com
29
43
  executables: []
@@ -58,7 +72,7 @@ homepage: https://github.com/meilisearch/meilisearch-rails
58
72
  licenses:
59
73
  - MIT
60
74
  metadata: {}
61
- post_install_message:
75
+ post_install_message:
62
76
  rdoc_options: []
63
77
  require_paths:
64
78
  - lib
@@ -74,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
88
  version: '0'
75
89
  requirements: []
76
90
  rubygems_version: 3.4.19
77
- signing_key:
91
+ signing_key:
78
92
  specification_version: 4
79
93
  summary: Meilisearch integration for Ruby on Rails.
80
94
  test_files: []