Skip to content

Commit

Permalink
Merge pull request #1332 from betagouv/fix/condition-replace
Browse files Browse the repository at this point in the history
Export des données en opent data : Correctif condition et suppression saut à la ligne
  • Loading branch information
pletelli authored Dec 2, 2024
2 parents d377796 + 6baae5c commit e787230
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions api/serializers/declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ def get_galenic_formulation(self, obj):
def get_declared_plants(self, obj):
return [
{
"nom": declared_plant.plant.name,
"partie": declared_plant.used_part.name,
"preparation": declared_plant.preparation.name,
"quantité_par_djr": declared_plant.quantity,
"nom": declared_plant.plant.name if declared_plant.plant else None,
"partie": declared_plant.used_part.name if declared_plant.used_part else None,
"preparation": declared_plant.preparation.name if declared_plant.preparation else None,
"quantité_par_djr": declared_plant.quantity if declared_plant.quantity else None,
"unite": declared_plant.unit.name,
}
if declared_plant.unit
Expand All @@ -374,8 +374,10 @@ def get_declared_plants(self, obj):
def get_declared_microorganisms(self, obj):
return [
{
"genre": declared_microorganism.microorganism.genus,
"espece": declared_microorganism.microorganism.species,
"genre": declared_microorganism.microorganism.genus if declared_microorganism.microorganism else None,
"espece": declared_microorganism.microorganism.species
if declared_microorganism.microorganism
else None,
"souche": declared_microorganism.strain
if declared_microorganism.strain
else None, # elle est normalement obligatoire mais quelques entrées ont pu être rentrées avant le required
Expand All @@ -392,7 +394,7 @@ def get_declared_substances(self, obj):
"quantité_par_djr": declared_substance.quantity,
"unite": declared_substance.unit.name,
}
if declared_substance.substance.name and declared_substance.quantity and declared_substance.unit
if declared_substance.substance and declared_substance.quantity and declared_substance.unit
else {}
for declared_substance in obj.declared_substances.all()
]
Expand Down
1 change: 1 addition & 0 deletions data/etl/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def clean_dataset(self):
# ---------------------------------------------------
self.df = self.df[columns_to_keep]
self.filter_dataframe_with_schema_cols()
self.df = self.df.replace({"\n": " ", "\r": " "}, regex=True)

def is_valid(self) -> bool:
files = prepare_file_validata_post_request(self.df)
Expand Down

0 comments on commit e787230

Please sign in to comment.