-
Notifications
You must be signed in to change notification settings - Fork 25
WAIT: Match interstitial duplicates on legal first name too #1826
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,16 +293,26 @@ def find_duplicate_people(first_name, last_name, email) | |
| normalized_last = NicknameMap.normalize(last_name) | ||
| normalized_first = NicknameMap.normalize(first_name) | ||
|
|
||
| # Match the typed first name (and its nickname variants) against either the | ||
| # stored first_name or legal_first_name, so a returning registrant whose legal | ||
| # name lives in legal_first_name (nickname in first_name) is still surfaced when | ||
| # they type their legal name. Mirrors the registration matcher in | ||
| # EventRegistrationServices::PublicRegistration#find_matching_person. | ||
| name_matches = Person.includes(:user) | ||
| .where("REPLACE(REPLACE(LOWER(last_name), '.', ''), ' ', '') = ?", normalized_last) | ||
| .where("REPLACE(REPLACE(LOWER(first_name), '.', ''), ' ', '') IN (?)", first_variants) | ||
| .where( | ||
| "REPLACE(REPLACE(LOWER(first_name), '.', ''), ' ', '') IN (:names) " \ | ||
| "OR REPLACE(REPLACE(LOWER(COALESCE(legal_first_name, '')), '.', ''), ' ', '') IN (:names)", | ||
| names: first_variants | ||
| ) | ||
| .limit(10) | ||
|
|
||
| name_matches.each do |person| | ||
| next if duplicate_ids.include?(person.id) | ||
|
|
||
| duplicate_ids.add(person.id) | ||
| exact_name = NicknameMap.normalize(person.first_name) == normalized_first | ||
| exact_name = NicknameMap.normalize(person.first_name) == normalized_first || | ||
| NicknameMap.normalize(person.legal_first_name) == normalized_first | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π€ From Claude: A legal-name hit counts as an exact name match (name-match badge + name-priority sort), matching how a first_name hit is treated. normalized_first is never blank here (guarded by |
||
| duplicates << format_duplicate(person, exact: exact_name, entered_email: email) | ||
| end | ||
| end | ||
|
|
||
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.
π€ From Claude: A legal-name hit counts as an exact name match ("name match" badge + name-priority sort), matching how a
first_namehit is treated.normalized_firstis never blank here (guarded byif first_name.presence), so a nil/blanklegal_first_namenormalizes to""and can't false-match.