- Aggiornato node.js alla versione 22.18.1
- Aggiornato tutti i pacchetti del server all'ultima versione. - passato mongoose da versione 5 a versione 6
This commit is contained in:
@@ -1102,237 +1102,6 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
|
||||
await CatProd.deleteMany({ idapp });
|
||||
await SubCatProd.deleteMany({ idapp });
|
||||
} else if (mydata.dbop === 'visuStat') {
|
||||
// ris = await User.visuUtentiNonInNavi(idapp);
|
||||
//} else if (mydata.dbop === 'creaNavi') {
|
||||
// const num = await Nave.generaNave(idapp, mydata, false);
|
||||
// ris = { num };
|
||||
//} else if (mydata.dbop === 'CreaNaviPersistenti') {
|
||||
// const num = await Nave.generaNave(idapp, mydata, true);
|
||||
// ris = { num };
|
||||
/*} else if (mydata.dbop === 'delNavi') {
|
||||
await Nave.setRiga(idapp, 1);
|
||||
await Nave.setCol(idapp, 1);
|
||||
const num = await Nave.deleteOne({ idapp });
|
||||
ris = { num };
|
||||
// } else if (mydata.dbop === 'delNaviNoStarted') {
|
||||
// await Nave.setRiga(idapp, 1);
|
||||
// await Nave.setCol(idapp, 1);
|
||||
// const num = await Nave.remove({ idapp, date_start: { $gte: tools.IncDateNow(-1000 * 60 * 60 * 24 * 3) } });
|
||||
// ris = { num };
|
||||
|
||||
} else if (mydata.dbop === 'delNaviProvvisorie') {
|
||||
|
||||
ris = await Nave.delNaviProvvisorie(idapp);
|
||||
|
||||
} else if (mydata.dbop === 'visuListaNave') {
|
||||
mystr = await Nave.showListaOrd(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'pulisciNonPresenzeInNave') {
|
||||
mystr = await Nave.pulisciNonPresenzeInNave(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'checkInserimentiUtentiInNave') {
|
||||
mystr = await Nave.checkIfDevoAggiungereInNave(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuListaIngresso') {
|
||||
mystr = await ListaIngresso.showListaOrd(idapp, false);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuListaIngressoNuovi') {
|
||||
mystr = await ListaIngresso.showListaOrd(idapp, true);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'GeneraGraduatoria') {
|
||||
mystr = await ListaIngresso.GeneraGraduatoria(idapp, true);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'AggiornaIndiceGraduatoria') {
|
||||
mystr = await Graduatoria.AggiornaIndiceGraduatoria(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'visuNaviUtentiEliminati') {
|
||||
ris = await Nave.visuNaviUtentiEliminati(idapp);
|
||||
} else if (mydata.dbop === 'convSubAccount') {
|
||||
ris = await User.convSubAccount(idapp);
|
||||
} else if (mydata.dbop === 'flagUtentiNaviNonPresenti') {
|
||||
ris = await User.flagUtentiNaviNonPresenti(idapp);
|
||||
} else if (mydata.dbop === 'generaFlotte') {
|
||||
ris = await NavePersistente.generaFlotte(idapp);
|
||||
} else if (mydata.dbop === 'mettiSognoePaypal') {
|
||||
ris = await User.mettiSognoePaypal(idapp, true);
|
||||
} else if (mydata.dbop === 'mettiSognoePaypalView') {
|
||||
ris = await User.mettiSognoePaypal(idapp, false);
|
||||
} else if (mydata.dbop === 'addNavePerUtentiNaviNonPresenti') {
|
||||
ris = await User.addNavePerUtentiNaviNonPresenti(idapp);
|
||||
} else if (mydata.dbop === 'creaTessituraeConv') {
|
||||
ris = await ListaIngresso.creaTessituraeConv(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'eliminaListeIngressoNascoste') {
|
||||
ris = await ListaIngresso.eliminaListeIngressoNascoste(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'RendiVisibileIrecordNascosti') {
|
||||
ris = await ListaIngresso.RendiVisibileIrecordNascosti(idapp);
|
||||
ris = { mystr };
|
||||
} else if (mydata.dbop === 'convNaviTessinListaIngressoRec') {
|
||||
let num = 0;
|
||||
|
||||
|
||||
const arrnavitess = await Nave.find({ idapp, num_tess: { $gte: 3 } });
|
||||
|
||||
for (const recnave of arrnavitess) {
|
||||
if (recnave.num_tess === 3 || recnave.num_tess === 5 || recnave.num_tess === 7) {
|
||||
const ind_order = recnave.ind_order;
|
||||
|
||||
// Prima controlla se ho già 2 record dello stesso ind_order, allora non lo faccio:
|
||||
const arringr = await ListaIngresso.find({ idapp, ind_order });
|
||||
let dafare = true;
|
||||
if (arringr.length > 0) {
|
||||
const arringrtest = await ListaIngresso.find({ idapp, ind_order }).distinct('num_tess');
|
||||
if (arringr.length !== arringrtest.length) {
|
||||
dafare = false; // Ci sono 2 o piu record! pertanto probabilmente l'ho già fatto!
|
||||
}
|
||||
}
|
||||
if (dafare) {
|
||||
// const user = await User.findByOldOrder(idapp, ind_order);
|
||||
const user = await User.findByIndOrder(idapp, ind_order);
|
||||
|
||||
if (!!user) {
|
||||
//let note = recnave.num_tess;
|
||||
// Crea record ListaIngresso
|
||||
const newrecingr = await ListaIngresso.addUserInListaIngresso(idapp, user.username, user.username, user.lang, false, true, recnave.created, '', true);
|
||||
|
||||
const fieldsvalue = {
|
||||
ind_order: newrecingr.ind_order,
|
||||
num_tess: 1,
|
||||
};
|
||||
|
||||
// Aggiorna la nave con l'Ind_order nuovo e il num_tess a 1
|
||||
await Nave.findOneAndUpdate({ _id: recnave._id }, { $set: fieldsvalue }, { new: false });
|
||||
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const arrnavitess2 = await Nave.find({ idapp, num_tess: 2 });
|
||||
|
||||
for (const recnave of arrnavitess2) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
ris = { num };
|
||||
|
||||
} else if (mydata.dbop === 'initListaIngresso') {
|
||||
// const aaa = await User.updateMany({ idapp }, { $set: { 'profile.nationality': 'IT' } });
|
||||
|
||||
const num = await ListaIngresso.updateMany({ idapp }, { $set: { added: false } });
|
||||
|
||||
ris = { num };
|
||||
} else if (mydata.dbop === 'ImpostaATuttiPaypal') {
|
||||
const listautenti = await User.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listautenti) {
|
||||
if (!rec._doc.profile.paymenttypes.includes('paypal')) {
|
||||
rec._doc.profile.paymenttypes = [...rec._doc.profile.paymenttypes, 'paypal'];
|
||||
const user = await User.findOneAndUpdate({ _id: rec._id }, { $set: { 'profile.paymenttypes': rec._doc.profile.paymenttypes } });
|
||||
// await rec.save();
|
||||
num++;
|
||||
}
|
||||
// const num = await User.f({ idapp }, { $set: { 'profile: false } });
|
||||
}
|
||||
|
||||
|
||||
ris = { num };
|
||||
} else if (mydata.dbop === 'numtessUno') {
|
||||
const listanavi = await ListaIngresso.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
if (!rec._doc.num_tess) {
|
||||
rec._doc.num_tess = 1;
|
||||
const risu = await ListaIngresso.findOneAndUpdate({ _id: rec._id }, { $set: { num_tess: rec._doc.num_tess } }, { new: false });
|
||||
// await rec.save();
|
||||
if (!!risu)
|
||||
num++;
|
||||
}
|
||||
// const num = await User.f({ idapp }, { $set: { 'profile: false } });
|
||||
}
|
||||
|
||||
|
||||
ris = { num };
|
||||
|
||||
} else if (mydata.dbop === 'Corregginumtess') {
|
||||
const listanavi = await Nave.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
const myarrrec = await Nave.find({ idapp, ind_order: rec.ind_order }).sort({ riga: 1, col: 1 });
|
||||
let indextess = 1;
|
||||
for (let ind = 0; ind < myarrrec.length; ind++) {
|
||||
if (myarrrec[ind].num_tess !== indextess && myarrrec[ind].num_tess === 1) {
|
||||
myarrrec[ind].num_tess = indextess;
|
||||
const risu = await Nave.findOneAndUpdate({ _id: myarrrec[ind]._id }, { $set: { num_tess: myarrrec[ind].num_tess } }, { new: false });
|
||||
num++;
|
||||
}
|
||||
indextess++;
|
||||
}
|
||||
}
|
||||
|
||||
ris = { num };
|
||||
*/
|
||||
/*
|
||||
}
|
||||
|
||||
else if (mydata.dbop === 'CreaNaviPersistenti') {
|
||||
const listanavi = await Nave.find({ idapp }).sort({riga: 1, col: 1});
|
||||
|
||||
let params = {
|
||||
idapp
|
||||
};
|
||||
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
let mypos = {
|
||||
idapp,
|
||||
riga: rec.riga,
|
||||
col: rec.col,
|
||||
numup: 3
|
||||
};
|
||||
tools.getRigaColByPosUp(mypos);
|
||||
let persistente = await NavePersistente.findByRigaCol(idapp, mypos.riga, mypos.col, 0);
|
||||
if (!persistente) {
|
||||
|
||||
params.date_start = rec.date_start;
|
||||
params.date_gift_chat_open = rec.date_gift_chat_open;
|
||||
params.riga = mypos.riga;
|
||||
params.col = mypos.col;
|
||||
if (rec.riga > 3) {
|
||||
params.riga1don = rec.riga;
|
||||
params.col1don = rec.col;
|
||||
} else {
|
||||
params.riga1don = rec.riga;
|
||||
params.col1don = rec.col;
|
||||
}
|
||||
if (params.riga > 0) {
|
||||
await NavePersistente.addRecordNavePersistenteByParams(params);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ris = { num }; */
|
||||
/*} else if (mydata.dbop === 'CorreggiDataGiftChat') {
|
||||
const listanavi = await NavePersistente.find({ idapp });
|
||||
let num = 0;
|
||||
for (let rec of listanavi) {
|
||||
const fieldsvalue = {
|
||||
date_gift_chat_open: tools.AddDate(rec.date_start, -7)
|
||||
};
|
||||
const risu = await NavePersistente.findOneAndUpdate({ _id: rec._id }, { $set: fieldsvalue }, { new: false });
|
||||
if (!!risu) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
ris = { num };
|
||||
*/
|
||||
} else if (mydata.dbop === 'creaUtentiTest') {
|
||||
|
||||
let num = 0;
|
||||
@@ -1655,8 +1424,8 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
const { City } = require('../models/city');
|
||||
const { Province } = require('../models/province');
|
||||
|
||||
await City.remove({});
|
||||
await Province.remove({});
|
||||
await City.deleteMany({});
|
||||
await Province.deleteMany({});
|
||||
|
||||
} else if (mydata.dbop === 'ConvTablesFromIntToString') {
|
||||
|
||||
@@ -1840,19 +1609,16 @@ async function ConvertiDaIntAStr(mytable) {
|
||||
myrec._doc.date_created = myrec._doc.date_updated;
|
||||
myrec._doc._id = idint + '';
|
||||
|
||||
let ris = await myrec.save((async function (err, doc) {
|
||||
if (doc) {
|
||||
ind++;
|
||||
//await mytable.findOneAndRemove({ _id: parseInt(doc._id, 10) });
|
||||
console.log('++Add (', ind, ')', doc._id);
|
||||
} else {
|
||||
const myid = parseInt(err.keyValue._id, 10) + 0;
|
||||
const canc = await mytable.findOneAndRemove({ _id: myid });
|
||||
if (canc)
|
||||
console.log('err', err.message, 'canc', canc._doc._id);
|
||||
}
|
||||
|
||||
}));
|
||||
try {
|
||||
const doc = await myrec.save();
|
||||
ind++;
|
||||
console.log('++Add (', ind, ')', doc._id);
|
||||
} catch (err) {
|
||||
const myid = parseInt(err.keyValue._id, 10) + 0;
|
||||
const canc = await mytable.findOneAndDelete({ _id: myid });
|
||||
if (canc)
|
||||
console.log('err', err.message, 'canc', canc._doc._id);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user