feat: aggiunta ricerca spudorata. progress: ripreso con il tentativo di invio delle mail che non creino nuovi ticket
This commit is contained in:
1 parent
3650bf5790
commit
8d24759a15
18 files changed
+1661
-98
No files matched your search
+10
-3
@@ -3,6 +3,12 @@ const router = express.Router();
|
||||
const pool = require('../db');
|
||||
const { db, logAttivita } = require('../activityDb');
|
||||
|
||||
function getLocalTimestamp() {
|
||||
const d = new Date();
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
||||
}
|
||||
|
||||
// Helper to fetch details of a list of tickets from OTRS DB
|
||||
async function fetchTicketsDetails(ticketIds) {
|
||||
if (!ticketIds || ticketIds.length === 0) return [];
|
||||
@@ -295,16 +301,17 @@ router.post('/close-end-of-day', async (req, res) => {
|
||||
stateId = fallbackRes.rows[0]?.id || 2;
|
||||
}
|
||||
|
||||
const localNow = getLocalTimestamp();
|
||||
const updatePlaceholders = openTicketIds.map((_, i) => `$${i + 1}`).join(', ');
|
||||
const updateQuery = `
|
||||
UPDATE ticket
|
||||
SET ticket_state_id = $${openTicketIds.length + 1},
|
||||
ticket_lock_id = 1,
|
||||
change_time = NOW(),
|
||||
change_by = $${openTicketIds.length + 2}
|
||||
change_time = $${openTicketIds.length + 2},
|
||||
change_by = $${openTicketIds.length + 3}
|
||||
WHERE id IN (${updatePlaceholders})
|
||||
`;
|
||||
await pool.query(updateQuery, [...openTicketIds, stateId, operatorId]);
|
||||
await pool.query(updateQuery, [...openTicketIds, stateId, localNow, operatorId]);
|
||||
|
||||
// Log activity
|
||||
logAttivita({
|
||||
|
||||
Reference in new issue
Block a user