-
Notifications
You must be signed in to change notification settings - Fork 37
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
(PC-32883)[API] chore: add atomic to offer routes #14942
base: master
Are you sure you want to change the base?
Conversation
api/src/pcapi/routes/pro/offers.py
Outdated
raise api_errors.ApiErrors(error.errors, status_code=400) | ||
|
||
except exceptions.OfferCreationBaseException as error: | ||
mark_transaction_as_invalid() |
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.
Pas besoin, le décorateur va le faire automatiquement en voyant passer l'exception
api/src/pcapi/routes/pro/offers.py
Outdated
except (exceptions.OfferCreationBaseException, exceptions.OfferEditionBaseException) as error: | ||
raise api_errors.ApiErrors(error.errors, status_code=400) | ||
except (exceptions.OfferCreationBaseException, exceptions.OfferEditionBaseException) as error: | ||
mark_transaction_as_invalid() |
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.
Pas besoin, le décorateur va le faire automatiquement en voyant passer l'exception
api/src/pcapi/routes/pro/offers.py
Outdated
@@ -284,13 +295,14 @@ def patch_draft_offer( | |||
raise api_errors.ResourceNotFoundError | |||
|
|||
rest.check_user_has_access_to_offerer(current_user, offer.venue.managingOffererId) | |||
try: | |||
with repository.transaction(): | |||
with atomic(): |
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 pense qu'on peut juste retirer le contexte manager. L'ancien n'était deja pas tres utile, maintenant il est complètement inutile :)
api/src/pcapi/routes/pro/offers.py
Outdated
@@ -313,8 +326,8 @@ def post_offer(body: offers_serialize.PostOfferBodyModel) -> offers_serialize.Ge | |||
offers_api.get_offerer_address_from_address(venue, body.address) if body.address else venue.offererAddress | |||
) | |||
rest.check_user_has_access_to_offerer(current_user, venue.managingOffererId) | |||
try: | |||
with repository.transaction(): | |||
with atomic(): |
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.
idem je ne pense pas que ce contexte manager soit encore utile
api/src/pcapi/routes/pro/offers.py
Outdated
except exceptions.OfferCreationBaseException as error: | ||
raise api_errors.ApiErrors(error.errors, status_code=400) | ||
except exceptions.OfferCreationBaseException as error: | ||
mark_transaction_as_invalid() |
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.
ide redondant avec l'exception
api/src/pcapi/routes/pro/offers.py
Outdated
@@ -465,7 +480,7 @@ def create_thumbnail(form: CreateThumbnailBodyModel) -> CreateThumbnailResponseM | |||
|
|||
image_as_bytes = form.get_image_as_bytes(request) | |||
|
|||
with transaction(): | |||
with atomic(): |
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.
idem contexte manager pas utile
api/src/pcapi/routes/pro/offers.py
Outdated
@@ -465,7 +480,7 @@ def create_thumbnail(form: CreateThumbnailBodyModel) -> CreateThumbnailResponseM | |||
|
|||
image_as_bytes = form.get_image_as_bytes(request) | |||
|
|||
with transaction(): | |||
with atomic(): |
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.
le create_mediation appele search.async_index_offer_ids
qui devrait être dans un on_commit
f992766
to
df7e0ba
Compare
with atomic(): | ||
try: |
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.
@Meewan ici aussi c'est inutile non ?
But de la pull request
Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-32883
Vérifications