- newsletter: prende la lista utenti (flag news_on)
- Abilita a Tutti la Newsletter news_on - isCommerciale - JobsInProgress - PCB: Corretto Totali che era a zero
This commit is contained in:
@@ -33,13 +33,27 @@ class MssqlMigrator {
|
||||
let indtab = 0;
|
||||
let indtabok = 0;
|
||||
const logs = [];
|
||||
for (const tableName of tableNames) {
|
||||
for (const rectable of tableNames) {
|
||||
try {
|
||||
const tableName = rectable.table;
|
||||
const usaDataOra = rectable.usaDataOra;
|
||||
const fieldId = rectable.fieldId;
|
||||
|
||||
const percentuale = ((indtab / numtables) * 100).toFixed(2);
|
||||
logs.push(`\n>> Recupero dati da MSSQL per la tabella: ${tableName} - (Completamento: ${percentuale}%)`);
|
||||
console.log(logs[logs.length - 1]);
|
||||
const dataQuery = `SELECT * FROM [${tableName}]`;
|
||||
let dataQuery = `SELECT * FROM ${tableName}`;
|
||||
|
||||
if (usaDataOra) {
|
||||
dataQuery = `SELECT T.* FROM ${tableName} T`;
|
||||
dataQuery += ` JOIN (
|
||||
SELECT ${fieldId}, MAX(DataOra) AS data
|
||||
FROM ${tableName}
|
||||
GROUP BY ${fieldId}
|
||||
) b ON T.${fieldId} = b.${fieldId} AND T.DataOra = b.data; `;
|
||||
}
|
||||
|
||||
console.log('query', dataQuery);
|
||||
|
||||
let dataResponse = null;
|
||||
|
||||
@@ -51,11 +65,12 @@ class MssqlMigrator {
|
||||
null,
|
||||
{ timeout: 900000 });
|
||||
} catch (error) {
|
||||
console.error('Error: ', error);
|
||||
console.error('Error: ', error.response?.data?.error || error.message || error);
|
||||
if (error.message === 'socket hang up') {
|
||||
console.log('Error: hangup, waiting 5 seconds and retrying...');
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
|
||||
|
||||
dataResponse = await axios.post(
|
||||
`${this.serverUrl}/query`,
|
||||
{ query: dataQuery },
|
||||
@@ -69,6 +84,7 @@ class MssqlMigrator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const records = dataResponse?.data;
|
||||
|
||||
if (!records || records.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user