Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAYLOAD] chore: cast type_siae as string #347

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading