fix(loyalty): resolve critical production readiness issues
Some checks failed
Some checks failed
- Add pessimistic locking (SELECT FOR UPDATE) on card write operations to prevent race conditions in stamp_service and points_service - Replace 16 console.log/error/warn calls with LogConfig.createLogger() in 3 storefront JS files (dashboard, history, enroll) - Delete all stale lu.json locale files across 8 modules (lb is the correct ISO 639-1 code for Luxembourgish) - Update architecture rules and docs to reference lb.json not lu.json - Add production-readiness.md report for loyalty module Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,19 @@ class CardService:
|
||||
.first()
|
||||
)
|
||||
|
||||
def get_card_for_update(self, db: Session, card_id: int) -> LoyaltyCard | None:
|
||||
"""Get a loyalty card by ID with a row-level lock (SELECT ... FOR UPDATE).
|
||||
|
||||
Note: Does not use joinedload to avoid LEFT OUTER JOIN which is
|
||||
incompatible with FOR UPDATE in PostgreSQL.
|
||||
"""
|
||||
return (
|
||||
db.query(LoyaltyCard)
|
||||
.filter(LoyaltyCard.id == card_id)
|
||||
.with_for_update()
|
||||
.first()
|
||||
)
|
||||
|
||||
def get_card_by_qr_code(self, db: Session, qr_code: str) -> LoyaltyCard | None:
|
||||
"""Get a loyalty card by QR code data."""
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user