fix(loyalty): resolve critical production readiness issues
Some checks failed
CI / ruff (push) Successful in 11s
CI / validate (push) Successful in 26s
CI / dependency-scanning (push) Successful in 32s
CI / pytest (push) Failing after 3h8m55s
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled

- 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:
2026-03-13 23:18:18 +01:00
parent 5dd5e01dc6
commit 4a1f71a312
18 changed files with 194 additions and 118 deletions

View File

@@ -1,5 +1,6 @@
// app/modules/loyalty/static/storefront/js/loyalty-dashboard.js
// Customer loyalty dashboard
const loyaltyDashboardLog = window.LogConfig.loggers.loyaltyDashboard || window.LogConfig.createLogger('loyaltyDashboard');
function customerLoyaltyDashboard() {
return {
@@ -20,7 +21,7 @@ function customerLoyaltyDashboard() {
showBarcode: false,
async init() {
console.log('Customer loyalty dashboard initializing...');
loyaltyDashboardLog.info('Customer loyalty dashboard initializing...');
await this.loadData();
},
@@ -32,7 +33,7 @@ function customerLoyaltyDashboard() {
this.loadTransactions()
]);
} catch (error) {
console.error('Failed to load loyalty data:', error);
loyaltyDashboardLog.error('Failed to load loyalty data:', error);
} finally {
this.loading = false;
}
@@ -47,11 +48,11 @@ function customerLoyaltyDashboard() {
this.rewards = response.program?.points_rewards || [];
this.locations = response.locations || [];
this.walletUrls = response.wallet_urls || { google_wallet_url: null, apple_wallet_url: null };
console.log('Loyalty card loaded:', this.card?.card_number);
loyaltyDashboardLog.info('Loyalty card loaded:', this.card?.card_number);
}
} catch (error) {
if (error.status === 404) {
console.log('No loyalty card found');
loyaltyDashboardLog.info('No loyalty card found');
this.card = null;
} else {
throw error;
@@ -66,7 +67,7 @@ function customerLoyaltyDashboard() {
this.transactions = response.transactions;
}
} catch (error) {
console.warn('Failed to load transactions:', error.message);
loyaltyDashboardLog.warn('Failed to load transactions:', error.message);
}
},

View File

@@ -1,5 +1,6 @@
// app/modules/loyalty/static/storefront/js/loyalty-enroll.js
// Self-service loyalty enrollment
const loyaltyEnrollLog = window.LogConfig.loggers.loyaltyEnroll || window.LogConfig.createLogger('loyaltyEnroll');
function customerLoyaltyEnroll() {
return {
@@ -28,7 +29,7 @@ function customerLoyaltyEnroll() {
showTerms: false,
async init() {
console.log('Customer loyalty enroll initializing...');
loyaltyEnrollLog.info('Customer loyalty enroll initializing...');
await this.loadProgram();
},
@@ -38,14 +39,14 @@ function customerLoyaltyEnroll() {
const response = await apiClient.get('/storefront/loyalty/program');
if (response) {
this.program = response;
console.log('Program loaded:', this.program.display_name);
loyaltyEnrollLog.info('Program loaded:', this.program.display_name);
}
} catch (error) {
if (error.status === 404) {
console.log('No loyalty program available');
loyaltyEnrollLog.info('No loyalty program available');
this.program = null;
} else {
console.error('Failed to load program:', error);
loyaltyEnrollLog.error('Failed to load program:', error);
this.error = I18n.t('loyalty.enrollment.errors.load_failed');
}
} finally {
@@ -73,7 +74,7 @@ function customerLoyaltyEnroll() {
if (response) {
const cardNumber = response.card?.card_number || response.card_number;
console.log('Enrollment successful:', cardNumber);
loyaltyEnrollLog.info('Enrollment successful:', cardNumber);
// Store wallet URLs for the success page (no auth needed)
if (response.wallet_urls) {
@@ -87,7 +88,7 @@ function customerLoyaltyEnroll() {
window.location.href = successUrl;
}
} catch (error) {
console.error('Enrollment failed:', error);
loyaltyEnrollLog.error('Enrollment failed:', error);
if (error.message?.includes('already')) {
this.error = I18n.t('loyalty.enrollment.errors.email_exists');
} else {

View File

@@ -1,5 +1,6 @@
// app/modules/loyalty/static/storefront/js/loyalty-history.js
// Customer loyalty transaction history
const loyaltyHistoryLog = window.LogConfig.loggers.loyaltyHistory || window.LogConfig.createLogger('loyaltyHistory');
function customerLoyaltyHistory() {
return {
@@ -21,7 +22,7 @@ function customerLoyaltyHistory() {
loading: false,
async init() {
console.log('Customer loyalty history initializing...');
loyaltyHistoryLog.info('Customer loyalty history initializing...');
await this.loadData();
},
@@ -33,7 +34,7 @@ function customerLoyaltyHistory() {
this.loadTransactions()
]);
} catch (error) {
console.error('Failed to load history:', error);
loyaltyHistoryLog.error('Failed to load history:', error);
} finally {
this.loading = false;
}
@@ -46,7 +47,7 @@ function customerLoyaltyHistory() {
this.card = response.card;
}
} catch (error) {
console.warn('Failed to load card:', error.message);
loyaltyHistoryLog.warn('Failed to load card:', error.message);
}
},
@@ -61,10 +62,10 @@ function customerLoyaltyHistory() {
this.transactions = response.transactions || [];
this.pagination.total = response.total || 0;
this.pagination.pages = Math.ceil(this.pagination.total / this.pagination.per_page);
console.log(`Loaded ${this.transactions.length} transactions`);
loyaltyHistoryLog.info(`Loaded ${this.transactions.length} transactions`);
}
} catch (error) {
console.error('Failed to load transactions:', error);
loyaltyHistoryLog.error('Failed to load transactions:', error);
}
},