fix: aggiunta nota ticket unito. feat: possiblità di visualizzare ticket in schede. feat: possibilità di creare un nuovo gruppo dall'interfaccia del ticket.

This commit is contained in:
2026-07-12 19:17:07 +02:00
parent e764c37d46
commit 748f777a31
10 changed files with 585 additions and 82 deletions
+31 -1
View File
@@ -1,4 +1,16 @@
const { Pool } = require('pg');
const { Pool, types } = require('pg');
// Override parser for TIMESTAMP WITHOUT TIME ZONE (type 1114) to return Date in UTC timezone
types.setTypeParser(1114, function(stringValue) {
if (!stringValue) return null;
// If it already has a timezone indicator or 'Z', parse normally
if (stringValue.endsWith('Z') || stringValue.includes('+') || stringValue.includes('-')) {
return new Date(stringValue);
}
// Standard OTRS timestamps are stored as UTC without offset (YYYY-MM-DD HH:mm:ss).
// Appending 'Z' tells JS engine to parse as UTC instead of local time.
return new Date(stringValue.replace(' ', 'T') + 'Z');
});
const dbType = (process.env.DB_TYPE || 'postgres').toLowerCase();
@@ -112,6 +124,16 @@ if (dbType === 'mysql' || dbType === 'mariadb') {
connectionLimit: 20,
idleTimeout: 30000,
connectTimeout: 5000,
timezone: '+00:00', // Parse dates from DB as UTC
});
// Ensure the session timezone is UTC for database functions like NOW()
this.mysqlPool.on('connection', (connection) => {
connection.query("SET time_zone = '+00:00'", (err) => {
if (err) {
console.error('[DB] Errore nell\'impostazione della time_zone UTC per MariaDB/MySQL:', err);
}
});
});
}
@@ -157,6 +179,14 @@ if (dbType === 'mysql' || dbType === 'mariadb') {
max: 20,
idleTimeoutMillis: 30000,
connectionTimeoutMillis: 5000,
options: '-c timezone=UTC', // Ensure connection timezone is UTC
});
// Ensure connection timezone is UTC via query fallback
pool.on('connect', (client) => {
client.query("SET TIME ZONE 'UTC'").catch(err => {
console.error('[DB] Errore nell\'impostazione della timezone UTC per Postgres:', err);
});
});
pool.on('error', (err) => {