Grosse Modifiche Completate !
This commit is contained in:
@@ -405,6 +405,7 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}, {
|
||||
lang: 1,
|
||||
index: 1,
|
||||
ind_order: 1,
|
||||
username: 1,
|
||||
aportador_solidario: 1,
|
||||
@@ -647,17 +648,24 @@ UserSchema.statics.getLastUser = function (idapp) {
|
||||
return User.findOne({
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).sort({ ind_order: -1 })
|
||||
}).sort({ index: -1 })
|
||||
};
|
||||
|
||||
UserSchema.statics.findByIndOrder = function (idapp, ind_order) {
|
||||
const User = this;
|
||||
|
||||
return User.getRecByIndOrder(idapp, ind_order);
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.findByIndex = function (idapp, index) {
|
||||
const User = this;
|
||||
|
||||
try {
|
||||
// ++Todo: non mettere tutti i campi !!
|
||||
return User.findOne({
|
||||
idapp,
|
||||
ind_order,
|
||||
index,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -711,7 +719,7 @@ UserSchema.pre('save', async function (next) {
|
||||
*/
|
||||
|
||||
next();
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
});
|
||||
@@ -855,12 +863,9 @@ UserSchema.statics.SetTelegramIdSuccess = async function (idapp, id, teleg_id) {
|
||||
UserSchema.statics.getLangByIndOrder = async function (idapp, ind_order) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, ind_order }, { lang: 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec) ? rec.lang : '';
|
||||
}).catch((e) => {
|
||||
return 'it';
|
||||
});
|
||||
const rec = await User.getSmallRecByIndOrder(idapp, ind_order);
|
||||
return (!!rec) ? rec.lang : '';
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -921,10 +926,14 @@ UserSchema.statics.getSmallRecByIndOrder = async function (idapp, ind_order) {
|
||||
},
|
||||
{
|
||||
idapp: 1,
|
||||
index: 1,
|
||||
ind_order: 1,
|
||||
old_order: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1
|
||||
lang: 1,
|
||||
surname: 1,
|
||||
'profile.teleg_id': 1,
|
||||
});
|
||||
|
||||
if (!!rec)
|
||||
@@ -938,6 +947,27 @@ UserSchema.statics.getSmallRecByIndOrder = async function (idapp, ind_order) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getRecByIndOrder = async function (idapp, ind_order) {
|
||||
|
||||
try {
|
||||
const rec = await ListaIngresso.getarray(idapp,
|
||||
{
|
||||
idapp,
|
||||
ind_order,
|
||||
deleted: false,
|
||||
});
|
||||
|
||||
if (!!rec)
|
||||
return rec[0];
|
||||
|
||||
return null;
|
||||
|
||||
} catch (e) {
|
||||
console.error('getRecByIndOrder', e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.getusersManagers = async function (idapp) {
|
||||
const User = this;
|
||||
@@ -1142,7 +1172,10 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
|
||||
|
||||
dashboard.arrposizioni = await Nave.getArrPosizioniByUsername(idapp, username);
|
||||
|
||||
const arrrec = await ListaIngresso.getProssimiInLista(idapp, true);
|
||||
let arrrec = [];
|
||||
if (dashboard.arrimbarchi.length > 0) {
|
||||
arrrec = await ListaIngresso.getProssimiInLista(idapp, true);
|
||||
}
|
||||
|
||||
for (let myimbarco of dashboard.arrimbarchi) {
|
||||
if (!!myimbarco.invitante_username)
|
||||
@@ -1158,6 +1191,7 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
|
||||
mypos._doc.nave_partenza = await NavePersistente.findByRigaColByDonatore(idapp, mypos.riga, mypos.col, 0);
|
||||
}
|
||||
|
||||
|
||||
//for (let indriga = 0; indriga < 10; indriga++) {
|
||||
// dashboard.navi_partenza.push(await Nave.getPrimaNaveByRiga(idapp, indriga));
|
||||
//}
|
||||
@@ -1196,7 +1230,7 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
|
||||
|
||||
myrec.nave_partenza = await NavePersistente.findByRigaColByDonatore(idapp, myrec.riga, myrec.col, 0);
|
||||
|
||||
arrnew.push(myrec);
|
||||
arrnew.push(myrec);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1212,6 +1246,7 @@ UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, us
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
UserSchema.statics.fixUsername = async function (idapp, aportador_solidario_ind_order, username) {
|
||||
const User = this;
|
||||
|
||||
@@ -1229,6 +1264,7 @@ UserSchema.statics.fixUsername = async function (idapp, aportador_solidario_ind_
|
||||
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
UserSchema.statics.findByCellAndNameSurname = function (idapp, cell, name, surname) {
|
||||
const User = this;
|
||||
@@ -1371,7 +1407,7 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
|
||||
visualizza = true;
|
||||
|
||||
if (visualizza) {
|
||||
mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.ind_order + '] [inv=' + user.numinvitati + ']'
|
||||
mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.index + '] [inv=' + user.numinvitati + ']'
|
||||
trovato = true;
|
||||
}
|
||||
|
||||
@@ -1524,7 +1560,7 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
date_reg: 1,
|
||||
ind_order: 1,
|
||||
index: 1,
|
||||
'profile.nationality': 1,
|
||||
}).sort({ date_reg: -1 }).limit(lastn).then((arr) => {
|
||||
//return JSON.stringify(arr)
|
||||
@@ -1717,26 +1753,10 @@ async function addUtentiInLista(idapp, mode, arrusers) {
|
||||
|
||||
}
|
||||
|
||||
UserSchema.statics.deveRitessersi = async function (idapp, ind_order) {
|
||||
|
||||
const myrec = await User.findOne({
|
||||
'idapp': idapp,
|
||||
'ind_order': ind_order,
|
||||
"profile.vuole_ritessersi": true
|
||||
});
|
||||
|
||||
return (!!myrec)
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsernameByIndOrder = async function (idapp, ind_order) {
|
||||
|
||||
const myrec = await User.findOne({
|
||||
'idapp': idapp,
|
||||
'ind_order': ind_order,
|
||||
}, { username: 1 });
|
||||
|
||||
return (!!myrec) ? myrec.username : ''
|
||||
const myrec = await User.getSmallRecByIndOrder(idapp, ind_order);
|
||||
return (!!myrec) ? myrec.username : '';
|
||||
|
||||
};
|
||||
|
||||
@@ -1755,7 +1775,7 @@ UserSchema.statics.ricalcolaIndex = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const arrusers = await User.find({ idapp }).sort({ ind_order: 1 });
|
||||
let index = 1;
|
||||
let index = 0;
|
||||
try {
|
||||
for (const user of arrusers) {
|
||||
let field = {
|
||||
@@ -1766,7 +1786,7 @@ UserSchema.statics.ricalcolaIndex = async function (idapp) {
|
||||
|
||||
const ris = await User.findOneAndUpdate({ _id: user._id }, { $set: field }, { new: false });
|
||||
}
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
@@ -1799,7 +1819,8 @@ UserSchema.statics.changeInvitante = async function (idapp, username, invitante_
|
||||
// **
|
||||
const rec_ingr = await ListaIngresso.findOne({ idapp, username: username });
|
||||
if (!!rec_ingr) {
|
||||
await ListaIngresso.findByIdAndUpdate(rec_ingr._id, { $set: { invitante_username, ind_order: ind_order_ingr } });
|
||||
// await ListaIngresso.findByIdAndUpdate(rec_ingr._id, { $set: { invitante_username, ind_order: ind_order_ingr } });
|
||||
await ListaIngresso.findByIdAndUpdate(rec_ingr._id, { $set: { invitante_username } });
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user