Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

School district auto-complete API - #18890

#18890
Merged
jopolsky merged 3 commits into
stagingcode-dot-org/code-dot-org:stagingfrom
school-district-autocompletecode-dot-org/code-dot-org:school-district-autocompleteCopy head branch name to clipboard
Nov 3, 2017
Merged

School district auto-complete API#18890
jopolsky merged 3 commits into
stagingcode-dot-org/code-dot-org:stagingfrom
school-district-autocompletecode-dot-org/code-dot-org:school-district-autocompleteCopy head branch name to clipboard

Conversation

@jopolsky

@jopolsky jopolsky commented Nov 3, 2017

Copy link
Copy Markdown

API and implementation for school districts auto-complete.

@jopolsky
jopolsky requested review from aoby and drewsamnick November 3, 2017 18:37

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this different from the MIN_QUERY_LENGTH in school_autocomplete?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove MIN_QUERY_LENGTH from school_autocomplete, I just didn't want to mess with that existing code much.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The get_matches code for school_autocomplete and school_district_autocomplete is almost identical. Can it be moved into the base class?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost but one does the zip code search.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the only difference, then perhaps it could still be common code with a parameter for the included search fields as a string array, which could be injected into the query with ? and then included_fields.join(',')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's right in the middle. I think it would be preferable to see how the auto-complete evolves before refactoring and adding complexity around conditionals. I can take another look later today if I still have time as well to see if there is any more opportunity to refactor.

Comment thread dashboard/config/routes.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need this constraint? I see it's specified on the next line too, but if I'm reading it correctly it's asking for at least one character that's not a /. Isn't that how Rails would parse the path anyway? I don't think this does anything.

I'm fairly certain that, for instance, districtsearch/foo/bar would already parse into params {q: 'foo', limit: 'bar'}.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drewsamnick can you comment on this comment? This was added after I did the initial school auto-complete.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constraint was put in place for schools to allow matching on a period. By default it won't match and that caused errors when searching for things like "St. Paul"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment on line 535-536.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Since that is pretty far down in the linked constraint description, let's add a small comment about the purpose too, e.g. "Constrain the q param to allow dots" before that link

Comment thread dashboard/lib/autocomplete_helper.rb Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like this rename

@jopolsky
jopolsky force-pushed the school-district-autocomplete branch from 3c9b3d3 to bd2589c Compare November 3, 2017 19:19
@jopolsky
jopolsky force-pushed the school-district-autocomplete branch from 6088cba to 7f274d2 Compare November 3, 2017 20:57
@jopolsky
jopolsky merged commit 84bba2a into staging Nov 3, 2017
@jopolsky
jopolsky deleted the school-district-autocomplete branch November 3, 2017 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.