Skip to content

[T3697] Household: the members sent by Connect replace the household's members - #2217

Merged
Danielgergely merged 1 commit into
18.0from
T3697-household-members
Nov 17, 2026
Merged

Danielgergely merged 1 commit into
18.0from
T3697-household-members

Conversation

@danpa32

@danpa32 danpa32 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

MyCompassion shows wrong family information for some children. Example: KE091300438 shows 6 brothers and 14 sisters, while Connect has 5 brothers and 3 sisters. Its household had 23 members instead of 10 (Lucy Njeri 11 times, Esther Wairimu 3 times, Peter Mbugua twice).

Cause

The "Household" mapping looked up each member of BeneficiaryHouseholdMemberList by name in all the household members of the database (search_relational_record + search_key: name). Every member with the same name was linked to the household being updated and overwritten with the received values. So:

  • members piled up in some households (all 41 "Patricia" members of the database are in one household);
  • the households they came from lost them.

In the database, this entry was also set to "append" by hand, so old members were never removed. The logic is old (same before T3151); duplicated rows exist since 2017.

Local copy of 26/10: 7,608 households with duplicated members (16,140 extra rows), 3,348 with wrong brother/sister counts, 1,806 of the 15,441 sponsored children affected.

Changes

child_compassion 18.0.1.1.3:

  • static/mappings/household.json: the member list is written in "overwrite" mode without searching by name. The list received from Connect replaces the members of the household (old members are deleted, ondelete="cascade"). Sponsored siblings are still linked to their child by global ID (Household Member mapping).
  • migrations/18.0.1.1.3/post-migration.py: reloads household.json (mappings are only loaded at install).
  • Tests tests/test_household_members.py: the same family received three times keeps its members; a member removed in Connect disappears; another family with a member of the same name is untouched. Two of the three fail with the old mapping.

Not in this PR

The existing wrong households are only corrected when Connect sends them again. A reload of the households of all sponsored children from Connect should be planned separately (procedure for the IT).

Tests

  • Module tests pass (3 new tests).
  • Upgrade tested on a copy of production: the migration reloads the mapping ("overwrite", no search key).

After deployment

Upgrade child_compassion.

…s members

The member list was searched by name in all the households of the database:
every member with the same name was moved into the household being updated
and overwritten, so families got duplicated members (wrong number of brothers
and sisters on MyCompassion) and others lost theirs. The list received from
Connect now replaces the members of the household. The migration reloads the
household mapping.

Assisted-by: claude-opus-5-5, medium, claude-code
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Reviews (1) · Last reviewed commit: "[T3697] Household: the members sent by C..." · Reviewed by Greptile

@Danielgergely
Danielgergely merged commit 6ad49a1 into 18.0 Nov 17, 2026
2 checks passed
@Danielgergely
Danielgergely deleted the T3697-household-members branch November 17, 2026 13:47
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.

2 participants