feat: add global ticket stats to getAllTickets endpoint
Returns pending, claimed, rejected counts for all tickets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6da53c3058
commit
4ab63ad068
|
|
@ -689,6 +689,22 @@ export const getAllTickets = asyncHandler(async (req, res) => {
|
|||
const countResult = await pool.query(countQuery, countParams);
|
||||
const total = parseInt(countResult.rows[0].count);
|
||||
|
||||
// Récupérer les stats globales (tous les tickets, sans pagination)
|
||||
const statsQuery = `
|
||||
SELECT
|
||||
COUNT(*) FILTER (WHERE status = 'PENDING') as pending,
|
||||
COUNT(*) FILTER (WHERE status = 'CLAIMED') as claimed,
|
||||
COUNT(*) FILTER (WHERE status = 'REJECTED') as rejected
|
||||
FROM tickets
|
||||
`;
|
||||
const statsResult = await pool.query(statsQuery);
|
||||
const stats = {
|
||||
pending: parseInt(statsResult.rows[0].pending) || 0,
|
||||
claimed: parseInt(statsResult.rows[0].claimed) || 0,
|
||||
rejected: parseInt(statsResult.rows[0].rejected) || 0,
|
||||
};
|
||||
console.log('📊 Stats calculées:', stats);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: result.rows,
|
||||
|
|
@ -696,6 +712,7 @@ export const getAllTickets = asyncHandler(async (req, res) => {
|
|||
page: parseInt(page),
|
||||
limit: parseInt(limit),
|
||||
totalPages: Math.ceil(total / limit),
|
||||
stats,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user