-
Notifications
You must be signed in to change notification settings - Fork 40
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-33423)[API] feat: add status isActive to headline_offer #15647
base: master
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (updated for commit 433c8e3): https://pc-pro-testing--pr15647-ogeber-pc-33423-add-zlx9x20n.web.app (expires Thu, 26 Dec 2024 15:28:45 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 032d233ee67e1c50d6af12e29c936c7076770eb1 |
ef1827d
to
d77ec93
Compare
api/src/pcapi/core/offers/api.py
Outdated
try: | ||
headline_offer = models.HeadlineOffer(offer=offer, venue=offer.venue, timespan=(datetime.datetime.utcnow(),)) | ||
db.session.add(headline_offer) | ||
db.session.commit() |
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.
Pourquoi le commit ici ? Si c'est une nouvelle route, je pense qu'on devrait utiliser @atomic et le remplacer par un flush.
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.
J'ai mis un loooooong commentaire au cas où
api/src/pcapi/alembic/versions/20241220T095131_4c3be4ff5274_add_timespan_on_headline_offer.py
Outdated
Show resolved
Hide resolved
ALTER TABLE headline_offer | ||
ADD CONSTRAINT exclude_offer_timespan EXCLUDE USING gist ( | ||
"offerId" | ||
WITH | ||
=, | ||
timespan | ||
WITH | ||
&& | ||
) |
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 Add Constraint prends un lock un peu énervé et sera bloqué par les select sur cette table. Si on a une requête qui fait une jointure sur cette table (et je vois qu'il en éxiste déjà), on aura surement un problème pour prendre le lock. Il faut les créer en NOT VALID et dans une migration suivante valider la contrainte
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.
Malheureusement, une contrainte EXCLUDE ne peut pas être créé en NOT VALID, ce n'est pas supporté par postgresql
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.
sqlalchemy.exc.NotSupportedError: (psycopg2.errors.FeatureNotSupported) EXCLUDE constraints cannot be marked NOT VALID
[SQL: ALTER TABLE headline_offer ADD CONSTRAINT exclude_offer_timespan EXCLUDE USING gist ("offerId" WITH =, timespan WITH &&) NOT VALID]
d77ec93
to
b79fb82
Compare
1d1c699
to
33a1c57
Compare
33a1c57
to
433c8e3
Compare
But de la pull request
Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-33423
commit 1 : retirer les contraintes d'unicité sur les offres & venues (pour préparer la suite)
commit 2: ajouter un timespan et des contraintes d'unicité sur l'overlap du timespan par offre et venue
commit 3: mettre à jour la fin du timespan si une offre n'est plus active (sera ajoutée à la crontab)
commit 4: mise à jour de la sandbox pour avoir des offres à la une valide
commit 5: mise à jour des routes GET offerer / headline_offer (PRO + NATIF)
Vérifications