Skip to content

Dedupe addresses & contact methods on person merge; flag multiple memberships - #2568

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/person-ded-per-audit
Draft

maebeale wants to merge 1 commit into
mainfrom
maebeale/person-ded-per-audit

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 two small after-merge reconcilers mirroring existing ones, plus a display-only membership warning

Merging two people now folds their duplicate addresses and phone numbers into one and keeps a single primary, so a merged record isn't left with identical duplicates — and admins get flagged when a merge leaves someone with more than one active membership.

What changed

  • Address dedup on merge — PersonServices::ReconcileAddresses folds addresses with identical details into one via ModelDeduper#merge, which auto-repoints the folded address's inbound FKs (contact_methods.address_id, invoices.bill_to_address_id, affiliations.organization_address_id) onto the survivor.
  • Contact-method dedup on merge — PersonServices::ReconcileContactMethods folds phones/sms/whatsapp with the same kind + value.
  • Single primary — for both, keeps the kept person's own pre-merge primary; if the kept person had none, falls back to the deleted person's; demotes the rest.
  • Multiple-membership warning — shown on the profile, edit page, and people index when a person has more than one uncancelled membership.

Decisions worth a look

  • Primary fallback: when the kept person had no primary, the deleted person's primary is preserved (matches the existing ReconcilePrimaryDesignations pattern), rather than leaving no primary. Say the word if you'd rather it always be the kept person's only.
  • "Multiple memberships" = more than one uncancelled. Membership already forbids two uncancelled per person, and cancelled historical renewals are normal, so flagging raw total would false-positive. This flags the actual anomaly a merge creates.

Tests

  • Unit specs for both reconcilers, end-to-end merge request specs (fold, keep-distinct, primary, FK repoint), and a membership-warning request spec (index/show/edit).
  • No user deduper exists (only people/orgs/workshops/categories/sectors/event_registrations wire up Dedupable).

🤖 Generated with Claude Code

…berships

A person merge moved both people's addresses and phone numbers onto the keeper
wholesale (neither table has a unique index to collapse them), leaving identical
duplicates and possibly two "primary" rows. Fold identical ones into one and
settle a single primary so a merged record stays clean.

Also flag a person carrying more than one uncancelled membership — the state a
merge leaves behind (moves bypass the one-uncancelled validation) — so admins
can consolidate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant