meilisearch-rails 0.13.1 → 0.14.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: 12e923de131ba62ca983afa2c0a998379a05c12010dd995a86ef968b0674804f
4
- data.tar.gz: 3b07fe9db72e017693694b2b243885dbe853f4cdfaa9606e1662d5a05547af84
3
+ metadata.gz: 24559c8e70fcdaef7392de52e689ed37427c1e87a8981e693f123c8b7348d75a
4
+ data.tar.gz: 415f7739643c82925fa54dc3b6a3d2dcf182d66969010fc84d3cf64a9444fc37
5
5
  SHA512:
6
- metadata.gz: '0968aafedae8f8b678d5cd94b5b4c587733b8fa9108076410eb612eb7923889f2f1e30e97b70697bcb46da2f492647363112989326bacf43ab35a29be7c30c5f'
7
- data.tar.gz: 5578f94eb44cee0c57e2fdff57a3bf955ab5db961b879dad33b3a35149807c176fb4daaf33d19a42d70ab7f68577f72f07cf1ddcf4aa9f52994c8f85f1743fae
6
+ metadata.gz: ce2015617e15a63f5d9fa39686b92272e83fb70c8ae66144847aa712ac51341ff1f56073006936fb568996105ee45142cedccfb5123befd79a033312efd37173
7
+ data.tar.gz: a906f6cc4bb10f6de8c38e19ab4225ffc7a1009517dedf0849972af3a6df50d6518371e66660477a8eb92291266bfea23e5ae135ebc3ca6f611e9e17828a4429
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --require spec_helper
data/README.md CHANGED
@@ -76,7 +76,7 @@ This package guarantees compatibility with [version v1.x of Meilisearch](https:/
76
76
 
77
77
  ## 🔧 Installation <!-- omit in toc -->
78
78
 
79
- This package requires Ruby version 2.7.0 or later and Rails 6.1 or later. It may work in older versions but it is not officially supported.
79
+ This package requires Ruby version 3.0 or later and Rails 6.1 or later. It may work in older versions but it is not officially supported.
80
80
 
81
81
  With `gem` in command line:
82
82
  ```bash
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  module MeiliSearch
4
4
  module Rails
5
- VERSION = '0.13.1'
5
+ VERSION = '0.14.1'
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
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  'Rakefile'
33
33
  ]
34
34
 
35
- s.required_ruby_version = '>= 2.6.0'
35
+ s.required_ruby_version = '>= 3.0.0'
36
36
 
37
- s.add_dependency 'meilisearch', '~> 0.26.0'
37
+ s.add_dependency 'meilisearch', '~> 0.28'
38
38
  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.13.1
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-28 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: meilisearch
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.26.0
19
+ version: '0.28'
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.26.0
26
+ version: '0.28'
27
27
  description: Meilisearch integration for Ruby on Rails. See https://github.com/meilisearch/meilisearch
28
28
  email: bonjour@meilisearch.com
29
29
  executables: []
@@ -66,14 +66,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 2.6.0
69
+ version: 3.0.0
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 3.1.6
76
+ rubygems_version: 3.4.19
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Meilisearch integration for Ruby on Rails.