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

Fix last sentry errors at CSV import #905

Merged
merged 2 commits into from
Aug 29, 2024
Merged
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
14 changes: 6 additions & 8 deletions data/csv_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
IngredientStatus,
IngredientSynonym,
Microorganism,
MicroorganismSynonym,
Part,
Plant,
PlantFamily,
Expand Down Expand Up @@ -54,31 +55,31 @@
# Les fichiers csv avec les Foreign Keys
"REF_ICA_INGREDIENT_AUTRE_SYNONYME.csv": IngredientSynonym,
"REF_ICA_PLANTE_SYNONYME.csv": PlantSynonym,
"REF_ICA_MICROORG_SYNONYME.csv": MicroorganismSynonym,
"REF_ICA_SUBSTANCE_ACTIVE_SYNONYME.csv": SubstanceSynonym,
# Les csv avec les relations ManyToMany
"REF_ICA_AUTREING_SUBSTACTIVE.csv": Ingredient,
"REF_ICA_PLANTE_SUBSTANCE.csv": Plant,
"REF_ICA_MOORG_SUBSTANCE.csv": "à récuperer",
"REF_ICA_MICROORG_SUBSTACTIVE.csv": Microorganism,
"REF_ICA_PARTIE_PL_A_SURVEILLER.csv": Part,
"REF_ICA_PARTIE_UTILE.csv": Part,
}

# Le fichier REF_ICA_PARTIE_PL_A_SURVEILLER n'est pas traité comme une relation car il correspond à un model à part entière
RELATION_CSV = [
"REF_ICA_AUTREING_SUBSTACTIVE.csv",
"REF_ICA_PLANTE_SUBSTANCE.csv",
]
RELATION_CSV = ["REF_ICA_AUTREING_SUBSTACTIVE.csv", "REF_ICA_PLANTE_SUBSTANCE.csv", "REF_ICA_MICROORG_SUBSTACTIVE.csv"]


class CSVImporter:
PREFIX_TO_MODEL_MAPPING = {
# Pour les tables de relation on garde le prefix correspondant au modèle dans lequel les données vont être importées
"INGA": Ingredient,
"MORG": Microorganism,
"PPLAN": PlantPart,
"PLTE": Plant,
"SBSACT": Substance,
"SYNAO": IngredientSynonym,
"SYNPLA": PlantSynonym,
"SYNMO": MicroorganismSynonym,
"SYNSBSTA": SubstanceSynonym,
"FAMPL": PlantFamily,
"UNT": SubstanceUnit,
Expand All @@ -88,9 +89,6 @@ class CSVImporter:
"STINGSBS": IngredientStatus,
"POPRS": Condition,
"": Population,
# Pour les tables de relation on garde le prefix correspondant au modèle dans lequel les données vont être importées
# "REF_ICA_AUTREING_SUBSTACTIVE.csv": "INGA",
# "REF_ICA_PLANTE_SUBSTANCE.csv": "PLTE",
# "REF_ICA_PARTIE_PL_A_SURVEILLER.csv": "",
# "REF_ICA_PARTIE_UTILE.csv": "",
}
Expand Down
Loading