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

(PC-32883)[API] chore: add atomic to offer routes #14942

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ogeber-pass
Copy link
Contributor

But de la pull request

Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-32883

Vérifications

  • J'ai écrit les tests nécessaires
  • J'ai mis à jour le fichier des plans de tests du portail pro si nécessaire
  • J'ai mis à jour la liste des routes et des titres de pages du portail pro si j'en ai rajouté/modifié ou supprimé une.
  • J'ai relu attentivement les migrations, en particulier pour éviter les locks, et je préviens les équipes Shérif et Data
  • J'ai ajouté des screenshots pour d'éventuels changements graphiques

raise api_errors.ApiErrors(error.errors, status_code=400)

except exceptions.OfferCreationBaseException as error:
mark_transaction_as_invalid()
Copy link
Contributor

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

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()
Copy link
Contributor

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

@@ -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():
Copy link
Contributor

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 :)

@@ -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():
Copy link
Contributor

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

except exceptions.OfferCreationBaseException as error:
raise api_errors.ApiErrors(error.errors, status_code=400)
except exceptions.OfferCreationBaseException as error:
mark_transaction_as_invalid()
Copy link
Contributor

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

@@ -465,7 +480,7 @@ def create_thumbnail(form: CreateThumbnailBodyModel) -> CreateThumbnailResponseM

image_as_bytes = form.get_image_as_bytes(request)

with transaction():
with atomic():
Copy link
Contributor

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

@@ -465,7 +480,7 @@ def create_thumbnail(form: CreateThumbnailBodyModel) -> CreateThumbnailResponseM

image_as_bytes = form.get_image_as_bytes(request)

with transaction():
with atomic():
Copy link
Contributor

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

@ogeber-pass ogeber-pass force-pushed the ogeber/pc-32883-add-atomic-to-offer-routes branch from f992766 to df7e0ba Compare November 6, 2024 16:37
Comment on lines +269 to +270
with atomic():
try:
Copy link
Contributor Author

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants