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

🚸(backend) on user search match emails by Levenstein distance #575

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

sampaccoud
Copy link
Member

@sampaccoud sampaccoud commented Jan 25, 2025

Purpose

When the query looks like an email (includes @) we should search by Levenstein distance and not by trigram anymore because we are just trying to prevent typing errors, not really proposing results to a search.

It is important to still propose results with a short Levenstein distance because it is frequent to forget a double letter in someone's name for example "Pacoud" or even "Pacou" instead of "Paccoud" and we want to prevent duplicates or failing on invitation.

Proposal

  • Activate Postgresql's fuzzystrmatch extension
  • Annotate and filter user searches by Levenstein distance
  • Update tests

We consider the query string to be an email as soon as it contains a "@" character. Trying harder to identify a string that is really an email would lead to weird behaviors like [email protected] looking like and email but if we continue typing [email protected] not looking like an email... before [email protected] finally looking like an email. The result would be jumping from one type of search to the other. As soon as there is a "@" in the query, we can be sure that the user is not looking for a name anymore and we can switch to matching by Levenstein distance.

@sampaccoud sampaccoud self-assigned this Jan 25, 2025
@sampaccoud sampaccoud added bug Something isn't working enhancement New feature or request python Pull requests that update Python code backend labels Jan 25, 2025
@sampaccoud sampaccoud force-pushed the fix-searching-user-by-email branch from 38b4e97 to b077411 Compare January 25, 2025 10:10
@sampaccoud sampaccoud force-pushed the fix-searching-user-by-email branch from e640b1b to 4e07c82 Compare January 28, 2025 16:09
When the query looks like an email (includes @) we search by
Levenstein distance because we are just trying to prevent typing
errors, not searching anymore.

It is important to still propose results with a short Levenstein
distance because it is frequent to forget a double letter in
someone's name for example "Pacoud" or even "pacou" instead of
"Paccoud" and we want to prevent duplicates or failing on
invitation.

We consider the query string to be an email as soon as it contains
a "@" character. Trying harder to identify a string that is really
an email would lead to weird behaviors like [email protected] looking
like and email but if we continue typing [email protected] not
looking like an email... before [email protected] finally looking
like an email. The result would be jumping from one type of search
to the other. As soon as there is a "@" in the query, we can be
sure that the user is not looking for a name anymore and we can
switch to matching by Levenstein distance.
@sampaccoud sampaccoud force-pushed the fix-searching-user-by-email branch from 4e07c82 to 9be5ae4 Compare January 28, 2025 16:11
@sampaccoud sampaccoud enabled auto-merge (rebase) January 28, 2025 16:12
@PanchoutNathan PanchoutNathan force-pushed the fix-searching-user-by-email branch 2 times, most recently from b2c161b to 0d5b791 Compare January 28, 2025 16:53
Refactor the endActions logic to show invite user row when searching by
email, removing the unnecessary length check for users
@PanchoutNathan PanchoutNathan force-pushed the fix-searching-user-by-email branch from 0d5b791 to 8fb5ed6 Compare January 28, 2025 17:05
@sampaccoud sampaccoud merged commit a39990d into main Jan 28, 2025
16 of 17 checks passed
@sampaccoud sampaccoud deleted the fix-searching-user-by-email branch January 28, 2025 17:15
@AntoLC AntoLC mentioned this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working enhancement New feature or request python Pull requests that update Python code urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants