Skip to content

Commit

Permalink
Résolution du bug de diffusion des préavis quand un numéro de télépho…
Browse files Browse the repository at this point in the history
…ne ou un email est un string vide (#3574)

## Linked issues

- Resolve #3573
  • Loading branch information
VincentAntoine authored Aug 23, 2024
2 parents 89ab58d + 85a8bcf commit 5ac0b55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions datascience/src/pipeline/shared_tasks/control_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ def fetch_control_units_contacts() -> pd.DataFrame:
.reset_index(drop=True)
)
contacts["email"] = contacts["control_unit_contacts"].apply(
lambda x: x.get("email") if x.get("isEmailSubscriptionContact") else None
lambda x: x.get("email")
if x.get("email") and x.get("isEmailSubscriptionContact")
else None
)

contacts["phone"] = contacts["control_unit_contacts"].apply(
lambda x: x.get("phone") if x.get("isSmsSubscriptionContact") else None
lambda x: x.get("phone")
if x.get("phone") and x.get("isSmsSubscriptionContact")
else None
)

email_and_phone_contacts = (
Expand Down
10 changes: 10 additions & 0 deletions datascience/tests/test_pipeline/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ def monitorenv_control_units_api_response() -> list:
"name": "OPERATIONAL_CENTER_HO",
"phone": "xx xx xx xx xx",
},
{
"id": 951357,
"controlUnitId": 2,
"email": "unused_email.adresse@somewhere",
"isEmailSubscriptionContact": False,
"isSmsSubscriptionContact": True,
"name": "OPERATIONAL_CENTER_HO",
"phone": "",
},
],
"isArchived": False,
"name": "Unité 2",
Expand Down Expand Up @@ -231,6 +240,7 @@ def monitorenv_control_units_api_response() -> list:
{
"id": 1541,
"controlUnitId": 6,
"email": "",
"isEmailSubscriptionContact": True,
"isSmsSubscriptionContact": False,
"name": "Référent police",
Expand Down

0 comments on commit 5ac0b55

Please sign in to comment.