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
Add query params to advanced_search_path if it is present. Fixes first requisite issue #2724 #3508
base: master
Are you sure you want to change the base?
Conversation
app/views/searches/show.html.erb
Outdated
@@ -5,7 +5,7 @@ | |||
<p><%= @error_msg %></p> | |||
</div> | |||
<% end %> | |||
<%= link_to t("advanced_search"), advanced_search_path, class: "t-link--gray t-link--has-arrow" %> | |||
<%= link_to t("advanced_search"), params[:query].present? ? advanced_search_path(query: params[:query]) : advanced_search_path, class: "t-link--gray t-link--has-arrow" %> |
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.
Would be advanced_search_path((query: params[:query]).compact)
enough?
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.
You're right! {query: params[:query]}
does the job. I've amended the commit and force-pushed it into my branch.
Codecov Report
@@ Coverage Diff @@
## master #3508 +/- ##
=======================================
Coverage 97.98% 97.98%
=======================================
Files 180 180
Lines 4357 4357
=======================================
Hits 4269 4269
Misses 88 88 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Thanks @simi for your review. While fixing the issue, I found out I've missed something important... this PR couldn't be so easy 😅 After clicking the link with However, if you pay attention to the individual search inputs for each search term, you can see they are blank ❌ The problem is that if you attempt to modify one of the small inputs, the main input query gets erased and you lose all the other search terms 😮 I can create a new method that matches the query string with something like But I think a better solution would be to leverage the file lib/elastic_searcher.rb to get the "n" separated query params (0 <= n <= 5). But I don't know if it is possible to leverage that file, I have this idea because the elastic searcher should separate the query params internally to do the advanced search. But I don't know if it is possible to expose the separated query params that are in the guts of elastic searcher. Also, I have not worked before with elastic search, so this API is strange to me. I'd like to know your feedback, or somebody else to fix the issue. Should I go with the regex approach? Try to leverage elastic searcher? Or is there something else I may be missing? Best, |
This is a follow up for #2833 . #2833 Adds the second feature request for #2724 . The current PR adds the first feature request in #2724 . I didn't understand the third feature request on that issue. If someone can write an example I can do the rest of the work.
I've tried to build a test for this branch, but it is my first time working with mini test, I've got an annoying error that the param is not permitted.... but it is a query params! It should be accepted. Here is the code snippet:
And the error:
I couldn't find any similar test in the codebase to take as an example.