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

(BSR)[API] feat: public api: apply atomic to event routes #14940

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeremieb-pass
Copy link
Contributor

But de la pull request

Appliquer le décorator atomic aux routes de création, d'édition et de suppression du module events de l'api publique.

@jeremieb-pass jeremieb-pass force-pushed the jeremieb/2024_11_06_journee_back_atomic_to_public_api branch 2 times, most recently from 1db6f2b to 18d33d4 Compare November 6, 2024 14:43
Copy link
Contributor

@rpaoloni-pass rpaoloni-pass left a 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 :)

db.session.flush()
except sa.exc.IntegrityError:
db.session.rollback()
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.

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

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

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

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

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

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

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.
@jeremieb-pass jeremieb-pass force-pushed the jeremieb/2024_11_06_journee_back_atomic_to_public_api branch from 18d33d4 to eacd34b Compare November 6, 2024 16:22
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.

4 participants