-
Notifications
You must be signed in to change notification settings - Fork 41
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-34594)[API] refactor: rework favorites to avoid using join-tables… #16310
base: master
Are you sure you want to change the base?
(PC-34594)[API] refactor: rework favorites to avoid using join-tables… #16310
Conversation
@@ -27,7 +26,8 @@ def post_collective_offer_favorites(authenticated_information: AuthenticatedInfo | |||
if redactor is None: | |||
raise ApiErrors({"message": "Redactor not found"}, status_code=403) | |||
|
|||
educational_api.add_offer_to_favorite_adage(redactor_id=redactor.id, offer_id=offer.id) | |||
redactor.favoriteCollectiveOffers.append(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.
Il se passe quoi si l'offre est déjà dans favoriteCollectiveOffers
? Pas grand chose I guess ?
educational_models.CollectiveOfferEducationalRedactor.query.filter_by( | ||
educationalRedactorId=redactor.id, collectiveOfferId=offer_id | ||
).delete(synchronize_session=False) | ||
redactor.favoriteCollectiveOffers.remove(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.
Est ce que ça fait une erreur si offer n'est pas dans favoriteCollectiveOffers
?
return serializers.ListCollectiveOfferTemplateResponseModel( | ||
collectiveOffers=[ | ||
typing.cast( | ||
serializers.CollectiveOfferTemplateResponseModel, | ||
serialize_collective_offer( | ||
offer=item.collective_offer_template, | ||
serializer=serializers.CollectiveOfferTemplateResponseModel, | ||
is_favorite=item.collective_offer_template.id in favorite_ids, | ||
is_favorite=item.collective_offer_template in redactor.favoriteCollectiveOfferTemplates, |
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.
Ptet un petit selectinload ou quoi sur favoriteCollectiveOfferTemplates dans find_redactor_by_email
, j'imagine que tous les 'offer in redactor.favorites' vont faire des requêtes en plus en l'état
… in queries
But de la pull request
Ticket Jira (ou description si BSR) : https://passculture.atlassian.net/browse/PC-34594
Vérifications