meilisearch-rails 0.14.0 → 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: ba5387112e0280c13ed074d356fdaa706c14a933d0a2ae540f16ecad75829db3
4
- data.tar.gz: 04560a2a843b527439d02abddf63d23ab218860e06fa6005ca4d5cc2cdf939cc
3
+ metadata.gz: 24559c8e70fcdaef7392de52e689ed37427c1e87a8981e693f123c8b7348d75a
4
+ data.tar.gz: 415f7739643c82925fa54dc3b6a3d2dcf182d66969010fc84d3cf64a9444fc37
5
5
  SHA512:
6
- metadata.gz: 8e3ca9d2407f083234b5a925ed31285d67d705c7e97ac07840989061a75ae6fbc9cdbf6e2f179d40f13d7b5751967727caaf872ae1d8b80a39494e6732692155
7
- data.tar.gz: 2d97cf8dee950fb9d9afe58b78eac6e4df2131eb0864a4a5b44bd247e97f79b759a66f6cf1882da37d7dca3a03b909ff5aacc71bd8063bf04e27ccf9b8dd4871
6
+ metadata.gz: ce2015617e15a63f5d9fa39686b92272e83fb70c8ae66144847aa712ac51341ff1f56073006936fb568996105ee45142cedccfb5123befd79a033312efd37173
7
+ data.tar.gz: a906f6cc4bb10f6de8c38e19ab4225ffc7a1009517dedf0849972af3a6df50d6518371e66660477a8eb92291266bfea23e5ae135ebc3ca6f611e9e17828a4429
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --require spec_helper
@@ -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.14.0'
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
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.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-07-10 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