Skip to content

Commit

Permalink
[PAYLOAD] chore: cast type_siae as string
Browse files Browse the repository at this point in the history
Merge pull request #347 from etalab/format-type-siae
  • Loading branch information
HAEKADI authored Mar 15, 2024
2 parents 64c4219 + 2fc2b16 commit 2cf366c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion aio/aio-proxy/aio_proxy/response/formatters/complements.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
format_collectivite_territoriale,
)
from aio_proxy.response.formatters.insee_bool import format_insee_bool
from aio_proxy.response.helpers import string_list_to_string
from aio_proxy.response.unite_legale_model import Complements


Expand Down Expand Up @@ -37,7 +38,7 @@ def get_field(field, default=None):
statut_entrepreneur_spectacle = get_field(
"statut_entrepreneur_spectacle",
)
type_siae = get_field("type_siae")
type_siae = string_list_to_string(get_field("type_siae"))
return Complements(
collectivite_territoriale=collectivite_territoriale,
convention_collective_renseignee=convention_collective_renseignee,
Expand Down
13 changes: 13 additions & 0 deletions aio/aio-proxy/aio_proxy/response/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,16 @@ def evaluate_field(field_value):
return None
else:
return None


def string_list_to_string(string_list):
if string_list is None:
return None
elif string_list.strip("[]") == "nan":
return None
else:
elements = string_list.strip("[]").split(", ")
# Remove surrounding quotes from each element
cleaned_elements = [element.strip("'") for element in elements]
# Join the elements into a single string
return ", ".join(cleaned_elements)

0 comments on commit 2cf366c

Please sign in to comment.