Skip to content

Commit

Permalink
prescribers.sync_ft_organizations: Stop ignoring missing siret items
Browse files Browse the repository at this point in the history
  • Loading branch information
rsebille committed Sep 5, 2024
1 parent 3d87f3c commit 7f8f21f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions itou/prescribers/management/commands/sync_ft_organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def update_information(self, data, *, wet_run=False):
Q(code_safir_pole_emploi="") | Q(code_safir_pole_emploi=None)
)
mapping = [
("siret", "siret"),
(lambda d: d.get("siret"), "siret"), # Don't break if the "required" siret is missing
(name_from_api_data, "name"),
(phone_from_api_data, "phone"),
(email_from_api_data, "email"),
Expand All @@ -106,17 +106,15 @@ def update_information(self, data, *, wet_run=False):
(coordinates_from_api_data, "coords"),
(insee_city_from_api_data, "insee_city"),
]
for item in yield_sync_diff(
[datum for datum in data if datum.get("siret")], "codeSafir", qs, "code_safir_pole_emploi", mapping
):
for item in yield_sync_diff(data, "codeSafir", qs, "code_safir_pole_emploi", mapping):
if item.kind == DiffItemKind.DELETION: # Ignore DELETION completely
continue
self.stdout.write(item.label)
if item.kind == DiffItemKind.SUMMARY: # Nothing more to do than display a message for SUMMARY
continue

safir = item.raw["codeSafir"]
siret = item.raw["siret"]
siret = item.raw.get("siret")
# Some agencies (with different location) share the same siret, this trigger the (siret, kind) unique
# constraint, as we don't really care about siret for France Travail organization we circumvent that by
# clearing the siret for the current one if it doesn't already exist or if is not the first one we see.
Expand Down

0 comments on commit 7f8f21f

Please sign in to comment.