54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
import { pool } from '../db.js';
|
|
|
|
async function testTicketAPIResponse() {
|
|
try {
|
|
console.log('\n🧪 TEST DE LA RÉPONSE API TICKETS\n');
|
|
|
|
// Simuler la requête API exacte
|
|
const result = await pool.query(`
|
|
SELECT
|
|
t.id,
|
|
t.code,
|
|
t.status,
|
|
t.played_at,
|
|
t.claimed_at,
|
|
t.validated_at,
|
|
t.created_at,
|
|
u.email as user_email,
|
|
u.first_name || ' ' || u.last_name as user_name,
|
|
p.name as prize_name,
|
|
p.type as prize_type,
|
|
p.value as prize_value,
|
|
v.first_name || ' ' || v.last_name as validated_by_name
|
|
FROM tickets t
|
|
LEFT JOIN users u ON t.user_id = u.id
|
|
LEFT JOIN prizes p ON t.prize_id = p.id
|
|
LEFT JOIN users v ON t.validated_by = v.id
|
|
WHERE p.type = 'INFUSEUR'
|
|
ORDER BY t.played_at DESC
|
|
LIMIT 3
|
|
`);
|
|
|
|
console.log(`Tickets trouvés: ${result.rows.length}\n`);
|
|
|
|
result.rows.forEach((ticket, idx) => {
|
|
console.log(`${idx + 1}. Ticket ${ticket.code}:`);
|
|
console.log(` prize_name: "${ticket.prize_name}"`);
|
|
console.log(` prize_type: "${ticket.prize_type}"`);
|
|
console.log(` prize_value: "${ticket.prize_value}"`);
|
|
console.log(` Type de prize_value: ${typeof ticket.prize_value}`);
|
|
console.log('');
|
|
});
|
|
|
|
await pool.end();
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Erreur:', error.message);
|
|
console.error(error.stack);
|
|
await pool.end();
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
testTicketAPIResponse();
|