-
Notifications
You must be signed in to change notification settings - Fork 26
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
Pattern search forms #2337
Draft
nimmolo
wants to merge
95
commits into
main
Choose a base branch
from
pattern-search-controllers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Pattern search forms #2337
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mo-nathan Thanks for checking it out. I know you're busy with mobile.
|
@JoeCohen — I would like to hear your feedback before I write any tests for this. @mo-nathan — Prefilled fields and selects are working again. |
Random suggestions: Observations
Names
Out of time & energy |
Prolly need to make the map centering text field diff from region.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Observation
andName
. These live at new endpoints,names/search/new
andobservations/search/new
, with new controllers, e.g.Names::FiltersController
.Query
for each model are different.requestjs
, similar to AJAX) to get the search form.Strategy
Conceptually it may seem straightforward to initiate a query from the form's keyword params, but they’re not ready yet: the
PatternSearch
class does validation and translating for both the values and the param keys. It translates human input values into values that are executable in AR/SQL, and translates our pattern search keywords into the actualQuery
class param names.So I considered two ways of handling these search params in the create action:
pattern
search string that an expert user would enter, if they knew how. This involves a couple steps:?pattern=&date=2024-08-24&id=2345
pattern
string expected byPatternSearch.new
. Change the&
into spaces, escape the commas in addresses, re-encode the whole string as a single pattern param, and send it to the index action atnames
, where if everything’s ok, we show the results.query_params
hash and initiate a query from thecreate
action, then send the query to the namesindex
action. Doing this without duplicatingPatternSearch
functionality would involve a new type of object in thePatternSearch
class that could validate the native query params and instantiate a query from that hash of params, rather than parsing the string (which is what it’s set up to do currently — there’s no direct “hash outlet” to plug into).The way i’m handling it is the first one. I actually prefer the directness of 2, and may try it in the future, but it made my head swim thinking about all the validation and error handling. 1 is a roundabout way of doing things: putting params back into a string and altering the string rather than keeping a clean param hash, but it leverages a lot of work that the
PatternSearch
class already does. The values for the params are human input, and require translation to be validquery_params
, so even if we used the nativeQuery
class param keys, we’d have to translate and validate the values.