-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/elasticsearch chewy #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| end | ||
|
|
||
| def search | ||
| @search_query = params[:search][:query] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а якщо сьорч поверне ніл?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app/services/book_search.rb
Outdated
| def self.search(query) | ||
| search_results = BooksIndex.query(query_string: {fields: [:title, :author, :description], query: query}).to_a | ||
| book_ids = search_results.map(&:id) | ||
| Book.where(id: book_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не тре цього, це не оптимально
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @@ -0,0 +1,6 @@ | |||
| <%= simple_form_for :search, url: search_books_path, method: :get, html: { class: "flex items-center" } do |f| %> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
огорни у семантичний тег search
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config/environment.rb
Outdated
| # Initialize the Rails application. | ||
| Rails.application.initialize! | ||
|
|
||
| BooksIndex.import(force: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тобі точно треба це?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| before(:each) do | ||
| BooksIndex.reset | ||
| BooksIndex.import(force: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нашо це?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
щоб ресетнути індекс і заповнити його актуальними даними перед тестами?)
spec/services/book_search_spec.rb
Outdated
|
|
||
| describe ".search" do | ||
| it "returns books matching the query" do | ||
| search_results = BookSearch.search("ruby") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а лет і сабджект для кого?))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Chewy Gem
Add Search Functionality
Change views to add search bar and search results
Add Active Storage Validations Gem to validate attachments
Add tests
User can search books by book name, author and words that may be in description.
Search by book name:

Search by author:

Search by any word may be in description:

If the search doesn't find anything it redirects to main page and shows notice:

If the search query is empty it redirects to main page and shows notice:
