Skip to content

Commit

Permalink
Merge branch 'main' into fix-race-condition-in-queued-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali authored Feb 12, 2024
2 parents 91437f1 + 53febb3 commit d32db1a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Run tests
run: bundle exec rspec
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
9 changes: 9 additions & 0 deletions lib/meilisearch-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ def initialize(index_uid, raise_on_failure, options)
end
end

# Maually define facet_search due to complications with **opts in ruby 2.*
def facet_search(*args, **opts)
SafeIndex.log_or_throw(:facet_search, @raise_on_failure) do
return MeiliSearch::Rails.black_hole unless MeiliSearch::Rails.active?

@index.facet_search(*args, **opts)
end
end

# special handling of wait_for_task to handle null task_id
def wait_for_task(task_uid)
return if task_uid.nil? && !@raise_on_failure # ok
Expand Down
15 changes: 15 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,21 @@
expect(results.facets_distribution['genre'].size).to eq(3)
end

it 'does not error on facet_search' do
genres = %w[Legend Fiction Crime].cycle
authors = %w[A B C].cycle

5.times do
Book.create! name: Faker::Book.title, author: authors.next, genre: genres.next
end

expect do
Book.index.facet_search('genre', 'Fic', filter: 'author = A')
Book.index.facet_search('genre', filter: 'author = A')
Book.index.facet_search('genre')
end.not_to raise_error
end

context 'with Marshal serialization' do
let(:found_books) { Book.search('*') }
let(:marshaled_books) { Marshal.dump(found_books) }
Expand Down
2 changes: 1 addition & 1 deletion spec/support/active_record_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class Book < ActiveRecord::Base
meilisearch synchronous: true, index_uid: safe_index_uid('SecuredBook'), sanitize: true do
searchable_attributes [:name]
typo_tolerance min_word_size_for_typos: { one_typo: 5, twoTypos: 8 }
filterable_attributes [:genre]
filterable_attributes %i[genre author]
faceting max_values_per_facet: 3

add_index safe_index_uid('BookAuthor') do
Expand Down

0 comments on commit d32db1a

Please sign in to comment.