Skip to content
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

Trigger autocomplete for 2 letter query if that is "US" #4730

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions server/routes/shared_api/autocomplete/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
'place_dcid': 'asia'
}] + TWO_WORD_CUSTOM_PLACES

# Exceptions for the 3 letter trigger rule. These queries can trigger on only two letters.
TWO_LETTER_TRIGGERS = {"us"}


def find_queries(user_query: str) -> List[str]:
"""Extracts subqueries to send to the Google Maps Predictions API from the entire user input.
Expand All @@ -78,8 +81,9 @@ def find_queries(user_query: str) -> List[str]:
else:
cumulative = word

# Only send queries 3 characters or longer.
if (len(cumulative) >= MIN_CHARACTERS_PER_QUERY):
# Only send queries 3 characters or longer, except for the exceptions in TWO_LETTER_TRIGGERS.
if (len(cumulative) >= MIN_CHARACTERS_PER_QUERY or
(len(cumulative) == 2 and cumulative.lower() in TWO_LETTER_TRIGGERS)):
queries.append(cumulative)

# Start by running the longer queries.
Expand Down
Loading