feat: aggiunta console giocosa all'interno del sistema. fix: correzione di un warning.
This commit is contained in:
1 parent
dcc0456070
commit
60259427d3
7 files changed
+805
-11
No files matched your search
+26
-1
@@ -313,12 +313,37 @@ router.get('/', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// GET /api/tickets/stats — Ticket statistics overview
|
||||
// ============================================================
|
||||
router.get('/stats', async (req, res) => {
|
||||
try {
|
||||
const totalRes = await pool.query('SELECT COUNT(*) as total FROM ticket');
|
||||
const openRes = await pool.query(
|
||||
`SELECT COUNT(*) as total FROM ticket t
|
||||
JOIN ticket_state ts ON t.ticket_state_id = ts.id
|
||||
JOIN ticket_state_type tst ON ts.type_id = tst.id
|
||||
WHERE tst.name IN ('new', 'open', 'pending auto', 'pending reminder')`
|
||||
);
|
||||
res.json({
|
||||
total_tickets: parseInt(totalRes.rows[0]?.total || 0),
|
||||
open_tickets: parseInt(openRes.rows[0]?.total || 0),
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Error fetching ticket stats:', err);
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// ============================================================
|
||||
// GET /api/tickets/:id — Single ticket detail
|
||||
// ============================================================
|
||||
router.get('/:id', async (req, res) => {
|
||||
router.get('/:id', async (req, res, next) => {
|
||||
try {
|
||||
const { id } = req.params;
|
||||
if (isNaN(id)) {
|
||||
return res.status(400).json({ error: 'ID ticket non valido' });
|
||||
}
|
||||
|
||||
const ticketResult = await pool.query(
|
||||
`SELECT
|
||||
|
||||
Reference in new issue
Block a user