-
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
(BSR)[API] feat: public api: apply atomic to event routes #14940
base: master
Are you sure you want to change the base?
(BSR)[API] feat: public api: apply atomic to event routes #14940
Conversation
1db6f2b
to
18d33d4
Compare
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.
il manque pas mal de on_commit, mais sinon j'ai pas vue trop de problemes :)
api/src/pcapi/core/offerers/api.py
Outdated
db.session.flush() | ||
except sa.exc.IntegrityError: | ||
db.session.rollback() | ||
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.
tu ne peux pas utiliser atomic ici puisque la fonction est aussi appelée hors de atomic. Il vaudrait mieux utiliser transaction
qui est plus safe dans ce contexte.
Je crois que j'ai deja migré cette fonction dans cette pr (que j'espere merger ce soir) #14083
raise api_errors.ApiErrors(error.errors, status_code=400) | ||
|
||
if body.image: | ||
utils.save_image(body.image, created_offer) |
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.
cette fonction a une pile d'appel qui finit par apeller
pass-culture-main/api/src/pcapi/core/offers/api.py:1016
search.async_index_offer_ids(
[offer.id],
reason=search.IndexationReason.MEDIATION_CREATION,
)
qui doit être defer a apres le commit via la fonction on_commit
utils.save_image(body.image, created_offer) | ||
|
||
try: | ||
offers_api.publish_offer(created_offer, user=None, publication_date=body.publication_date) |
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.
cette fonction a une pile d'appel qui finit par apeller
pass-culture-main/api/src/pcapi/core/external/compliance.py:21-23
ces deux fonciton devraient êter apellées dans des on_commit
offer = offers_api.update_offer(offer, offer_body) | ||
if body.image: | ||
utils.save_image(body.image, offer) | ||
offer = offers_api.update_offer(offer, offer_body) |
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.
Cette fonction finie par apeller:pass-culture-main/api/src/pcapi/core/offers/api.py:427
qui devrait être apellée dans un on_commit
idem pour
pass-culture-main/api/src/pcapi/core/mails/transactional/bookings/booking_withdrawal_updated.py:70
id_at_provider=update_body.get("id_at_provider", offers_api.UNCHANGED), | ||
editing_provider=current_api_key.provider, | ||
) | ||
offers_api.edit_price_category( |
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.
cette fonction finie par apeller
pass-culture-main/api/src/pcapi/core/offers/api.py:833
qui devrait aller dans un on_commit
) | ||
|
||
new_dates.append( | ||
offers_api.create_stock( |
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.
cette fonction finie par apeller pass-culture-main/api/src/pcapi/core/offers/api.py:742
qui devrait aller dans un on_commit
@@ -565,6 +578,7 @@ def get_event_stocks(event_id: int, query: serialization.GetEventStocksQueryPara | |||
) | |||
), | |||
) | |||
@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.
dans cette fonction on appele delete_stock qui envois un mail et qui devrait être dans un on_commit
Add `atomic` decorator to post/patch/delete event routes.
18d33d4
to
eacd34b
Compare
But de la pull request
Appliquer le décorator
atomic
aux routes de création, d'édition et de suppression du moduleevents
de l'api publique.