You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(likes): Make like/unlike operations atomic
Wrap the like and unlike logic in `django.db.transaction.atomic()` to ensure that the creation/deletion of the like and the update of the promo's `like_count` are performed as a single, indivisible operation. This prevents potential race conditions and data inconsistency.
Add `promo.refresh_from_db()` after the `F()` expression update to ensure the promo object reflects the latest database state.
0 commit comments