-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(Validata): Import achats: ajout d'appels à Validata et renvoyer les erreurs #4949
Conversation
16396a7
to
17b25bd
Compare
self.data_schema = json.load(open("data/schemas/imports/achats.json")) | ||
self.expected_header = [field["name"] for field in self.data_schema["fields"]] | ||
self.schema_url = ( | ||
"https://raw.githubusercontent.com/betagouv/ma-cantine/refs/heads/staging/data/schemas/imports/achats.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On peut aussi en profiter pour refactor la fonction validate en passant le fichier directement
voir code compl'alim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dans ton exemple le schema est aussi une url il me semble ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oui pardon, j'ai confondu avec le fichier
bb31e03
to
314296d
Compare
8a4f83b
to
60764b2
Compare
0b86819
to
43b6c1c
Compare
api/views/utils.py
Outdated
@@ -31,6 +34,45 @@ def _get_file_digest(self): | |||
file_hash.update(row) | |||
return file_hash.hexdigest() | |||
|
|||
def _get_file_dialect(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
je vais basculer la logique "dialect" dans la PR précédente
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
et j'ai basculé la logique header dans une PR séparée
60764b2
to
36b538b
Compare
76c1e8e
to
6be0241
Compare
36b538b
to
9a82b53
Compare
87eb3d6
to
5ef3aa0
Compare
5ef3aa0
to
9dc53a8
Compare
b902895
to
e837692
Compare
e837692
to
bf22a83
Compare
return response.json()["report"] | ||
|
||
|
||
def process_errors(report): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question à trancher : est-ce qu'on pre-process les erreurs Validata ici (dans le backend), ou coté frontend ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Côté front +1 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes go pour le front ! du coup je renvoi un maximum d'infos dans l'objet
b9210ab
to
aac7a7a
Compare
# Reset the file pointer to the beginning | ||
file.seek(0) | ||
response = requests.post( | ||
"https://api.validata.etalab.studio/validate", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
à noter que ca fait des appels API à chaque lancement de tests CI 👀
9699526
to
4b4d446
Compare
4b4d446
to
4a21643
Compare
4a21643
to
c3c174f
Compare
api/tests/test_import_purchases.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remarque mais pas bloquant, en fait on aurait aussi pu simplifier les tests en vérifiant le "title" et non "message" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
je vois ton message que maintenant, mais en effet maintenant qu'on a le title... je note de corriger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
je vais laisser tel quel, vu que ailleurs (les autres erreurs) on fait les test sur le champ message aussi..
à voir comment on pourra homogénéiser tout ça
c3c174f
to
1560e7f
Compare
Nouveau fichier
common/api/validata.py