Skip to content

Commit

Permalink
Merge pull request #1241 from rapidpro/ignore-contacts-missing-urns
Browse files Browse the repository at this point in the history
Do not sync empty contacts not having URNs set
  • Loading branch information
norkans7 authored Sep 18, 2024
2 parents 4f5436c + 8287189 commit 478fb1c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ureport/backend/rapidpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def local_kwargs(self, org, remote):
if reporter_group.lower() not in contact_groups_names:
return None

if not remote.urns:
return None

org_state_boundaries_data, org_district_boundaries_data, org_ward_boundaries_data = self.get_boundaries_data(
org
)
Expand Down Expand Up @@ -271,10 +274,7 @@ def local_kwargs(self, org, remote):
else:
gender = ""

scheme = ""
if remote.urns:
primary_urn = remote.urns[0]
scheme, path = primary_urn.split(":", 1)
scheme, path = remote.urns[0].split(":", 1)

return {
"backend": self.backend,
Expand Down
19 changes: 19 additions & 0 deletions ureport/backend/tests/test_rapidpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,25 @@ def test_local_kwargs(self):

self.assertIsNone(self.syncer.local_kwargs(self.nigeria, temba_contact))

temba_contact = TembaContact.create(
uuid="C-006",
name="Jan",
urns=[],
groups=[ObjectRef.create(uuid="G-001", name="ureporters"), ObjectRef.create(uuid="G-007", name="Actors")],
fields={
"registration_date": None,
"state": None,
"lga": None,
"occupation": None,
"born": None,
"gender": None,
},
language="eng",
created_on=json_date_to_datetime("2013-01-02T03:04:05.000"),
)

self.assertIsNone(self.syncer.local_kwargs(self.nigeria, temba_contact))

temba_contact = TembaContact.create(
uuid="C-006",
name="Jan",
Expand Down

0 comments on commit 478fb1c

Please sign in to comment.