Aggiornamenti
This commit is contained in:
@@ -53,7 +53,7 @@ CalZoomSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp, date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 3) } };
|
||||
|
||||
return await CalZoom.find(myfind).sort({ date_start: 1 }).limit(6);
|
||||
return await CalZoom.find(myfind).sort({ date_start: 1 }).limit(10);
|
||||
};
|
||||
|
||||
CalZoomSchema.statics.getNextZoom = async function (idapp) {
|
||||
|
||||
@@ -17,7 +17,9 @@ const cfgserverSchema = new Schema({
|
||||
required: true,
|
||||
trim: true,
|
||||
minlength: 1,
|
||||
unique: true,
|
||||
},
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
|
||||
@@ -29,9 +29,6 @@ const ListaIngressoSchema = new mongoose.Schema({
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
indprimario: {
|
||||
type: Number,
|
||||
},
|
||||
ind_order: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -52,24 +49,6 @@ const ListaIngressoSchema = new mongoose.Schema({
|
||||
|
||||
});
|
||||
|
||||
ListaIngressoSchema.pre('save', async function (next) {
|
||||
if (this.isNew) {
|
||||
const myrec = await ListaIngresso.findOne().limit(1).sort({ indprimario: -1 });
|
||||
if (!!myrec) {
|
||||
if (myrec._doc.indprimario === 0)
|
||||
this.indprimario = 1;
|
||||
else
|
||||
this.indprimario = myrec._doc.indprimario + 10;
|
||||
|
||||
} else {
|
||||
this.indprimario = 10;
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
// ListaIngressoSchema.methods.toJSON = function () {
|
||||
// const ListaIngresso = this;
|
||||
// const userObject = ListaIngresso.toObject();
|
||||
@@ -94,13 +73,6 @@ ListaIngressoSchema.statics.getTotInLista = async function (idapp) {
|
||||
return await ListaIngresso.count(myfind);
|
||||
};
|
||||
|
||||
ListaIngressoSchema.statics.getOrderedList = function (idapp) {
|
||||
const ListaIngresso = this;
|
||||
|
||||
return ListaIngresso.findOne({ idapp }).sort({ indprimario: -1 })
|
||||
};
|
||||
|
||||
|
||||
ListaIngressoSchema.statics.findByIndOrder = function (idapp, ind_order) {
|
||||
const ListaIngresso = this;
|
||||
|
||||
@@ -271,10 +243,12 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov
|
||||
num_tess: 1,
|
||||
added: 1,
|
||||
deleted: 1,
|
||||
sospeso: 1,
|
||||
};
|
||||
|
||||
let myfilter2 = {
|
||||
username: { $exists: true },
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
};
|
||||
|
||||
if (solonuovi) {
|
||||
@@ -292,7 +266,7 @@ ListaIngressoSchema.statics.getProssimiInLista = async function (idapp, solonuov
|
||||
}, myobjField, myfilter2);
|
||||
}
|
||||
|
||||
arrrec = await ListaIngresso.aggregate(myquery).sort({ indprimario: 1 })
|
||||
arrrec = await ListaIngresso.aggregate(myquery).sort({ ind_order: 1 })
|
||||
.then(async (arrlista) => {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
@@ -34,9 +34,6 @@ const NaveSchema = new mongoose.Schema({
|
||||
col: {
|
||||
type: Number,
|
||||
},
|
||||
indprimario: {
|
||||
type: Number,
|
||||
},
|
||||
ind_order: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -117,19 +114,6 @@ NaveSchema.statics.findById = function (idapp, id) {
|
||||
|
||||
};
|
||||
|
||||
NaveSchema.statics.findByIndPrimario = function (idapp, indprimario) {
|
||||
const Nave = this;
|
||||
|
||||
try {
|
||||
return Nave.findOne({
|
||||
idapp,
|
||||
indprimario,
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
NaveSchema.statics.getFieldsForSearch = function () {
|
||||
return [{ field: 'ind_order', type: tools.FieldType.number },
|
||||
@@ -419,6 +403,8 @@ function getQueryProj(myfilter) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
username: 1,
|
||||
deleted: 1,
|
||||
sospeso: 1,
|
||||
'profile.paymenttypes': 1,
|
||||
'profile.email_paypal': 1,
|
||||
'profile.cell': 1,
|
||||
@@ -429,7 +415,6 @@ function getQueryProj(myfilter) {
|
||||
received_gift: 1,
|
||||
date_received_gift: 1,
|
||||
num_tess: 1,
|
||||
indprimario: 1,
|
||||
parent_id: 1,
|
||||
riga: 1,
|
||||
col: 1,
|
||||
@@ -458,6 +443,7 @@ function getQueryProj(myfilter) {
|
||||
$replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] }, "$$ROOT"] } }
|
||||
// $replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ["$user", 0] },] } }
|
||||
},
|
||||
{ $match: { $or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }] } },
|
||||
{ $project: myobjField }
|
||||
];
|
||||
|
||||
@@ -903,7 +889,6 @@ async function addRecordNaveByParams(params, siRitesse) {
|
||||
|
||||
let myNave = new Nave({
|
||||
idapp: params.idapp,
|
||||
indprimario: params.indprimario,
|
||||
ind_order: params.ind_order,
|
||||
riga: params.riga,
|
||||
col: params.col,
|
||||
@@ -1026,7 +1011,6 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
|
||||
if (ris.deveritessersi) {
|
||||
console.log('Si deve ritesere: [riga=', params.riga, 'col', params.col, ']');
|
||||
if (ris.deveritessersi) {
|
||||
params.indprimario = recmediatore.indprimario;
|
||||
params.ind_order = recmediatore.ind_order;
|
||||
params.id = recmediatore._id;
|
||||
params.num_tess = ris.num_tess + 1;
|
||||
@@ -1039,7 +1023,6 @@ NaveSchema.statics.addUserFromListaIngresso_IntoNave = async function (init, ida
|
||||
if ((params.riga === 4 + 3) && (params.col === (8 * 2) + 3)) {
|
||||
// Si ritesse il Fondo AYNI nella Nave 3.3
|
||||
const userFondo = await User.findByIndOrder(idapp, 0);
|
||||
params.indprimario = userFondo.indprimario;
|
||||
params.ind_order = userFondo.ind_order;
|
||||
params.id = userFondo._id;
|
||||
params.num_tess = userFondo.num_tess;
|
||||
@@ -1076,7 +1059,7 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
|
||||
|
||||
const recfindFondo = await Nave.findByRigaCol(params.idapp, 0, 0, true);
|
||||
if (!recfindFondo) {
|
||||
let myNave = new Nave({ idapp, indprimario: 0, ind_order: 0, riga: 0, col: 0 });
|
||||
let myNave = new Nave({ idapp, ind_order: 0, riga: 0, col: 0 });
|
||||
myNave.created = new Date();
|
||||
myNave.parent_id = ObjectID("5e592aecbfd0b75f3021d9c9");
|
||||
await myNave.save();
|
||||
@@ -1094,7 +1077,6 @@ NaveSchema.statics.generaNave = async function (idapp, mydata) {
|
||||
let index = 0;
|
||||
for (const reclista of arrlistaingresso) {
|
||||
|
||||
params.indprimario = reclista.indprimario;
|
||||
params.ind_order = reclista.ind_order;
|
||||
params.id = reclista._id;
|
||||
params.num_tess = reclista.num_tess;
|
||||
@@ -1114,8 +1096,6 @@ async function addUserToNave(idapp, rec) {
|
||||
|
||||
let params = {};
|
||||
|
||||
params.indprimario = rec.indprimario;
|
||||
params.ind_order = rec.ind_order;
|
||||
params.id = rec._id;
|
||||
params.num_tess = rec.num_tess;
|
||||
|
||||
@@ -1181,10 +1161,12 @@ NaveSchema.statics.visuNaviUtentiEliminati = async function (idapp) {
|
||||
for (const rec of arrrec) {
|
||||
if (!rec.username) {
|
||||
let navepersistente = await NavePersistente.findByRigaColByDonatore(idapp, rec.riga, rec.col, 0);
|
||||
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order;
|
||||
mystr += ' num_tess = ' + rec.num_tess;
|
||||
mystr += '\n';
|
||||
conta++;
|
||||
if (!!navepersistente) {
|
||||
mystr += '[' + conta + '] [NAVI ' + navepersistente.riga + '.' + navepersistente.col + '] [' + rec.riga + '.' + rec.col + '] ' + rec.ind_order;
|
||||
mystr += ' num_tess = ' + rec.num_tess;
|
||||
mystr += '\n';
|
||||
conta++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1235,7 +1217,7 @@ NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, co
|
||||
const Nave = this;
|
||||
|
||||
coldonatoreIni = ((colnave - 1) * 64) + (1);
|
||||
coldonatoreFine = coldonatoreIni + (64);
|
||||
coldonatoreFine = coldonatoreIni + (63);
|
||||
|
||||
const myquery = getQueryProj({
|
||||
idapp,
|
||||
@@ -1271,6 +1253,61 @@ NaveSchema.statics.getDonatoridelSognatore = async function (idapp, riganave, co
|
||||
|
||||
};
|
||||
|
||||
NaveSchema.statics.ricalcolaNave = async function (idapp, nave, riga1don, col1don, ricalcola, index) {
|
||||
const Nave = this;
|
||||
|
||||
try {
|
||||
if (nave === null) {
|
||||
nave = await NavePersistente.findByRigaColByDonatore(idapp, riga1don, col1don, 0);
|
||||
}
|
||||
nave.rec = await Nave.getNaveByRigaCol(idapp, nave.riga1don, nave.col1don);
|
||||
|
||||
if (nave.provvisoria || (ricalcola && (nave.DoniConfermati === nave.DoniTotali) && (nave.DoniTotali >= 7) && nave.DoniMancanti === 0 && nave.DoniAttesaDiConferma === 0)) {
|
||||
// gia fatto
|
||||
|
||||
} else {
|
||||
nave.index = index;
|
||||
|
||||
nave.DoniTotali = 0;
|
||||
nave.DoniAttesaDiConferma = 0;
|
||||
nave.DoniMancanti = 0;
|
||||
nave.DoniConfermati = 0;
|
||||
|
||||
const { User } = require('./user');
|
||||
|
||||
if (!!nave.tutor)
|
||||
nave.tutor_namesurname = await User.getNameSurnameByUsername(idapp, nave.tutor);
|
||||
|
||||
if (!!nave.rec) {
|
||||
if (!!nave.rec.donatore) {
|
||||
nave.DoniTotali = nave.rec.donatore.arrdonatori.filter((rec) => (!(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0))).reduce((sum, item) => sum + 1, 0);
|
||||
nave.DoniAttesaDiConferma = nave.rec.donatore.arrdonatori.filter((rec) => (!!rec.date_made_gift && !rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0))).reduce((sum, item) => sum + 1, 0);
|
||||
nave.DoniMancanti = nave.rec.donatore.arrdonatori.filter((rec) => (!rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0))).reduce((sum, item) => sum + 1, 0);
|
||||
nave.DoniConfermati = nave.rec.donatore.arrdonatori.filter((rec) => rec.made_gift && !(rec.ind_order === nave.rec.donatore.recmediatore.ind_order && (rec.num_tess % 2) === 0)).reduce((sum, item) => sum + 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
const fieldsvalue = {
|
||||
DoniAttesaDiConferma: nave.DoniAttesaDiConferma,
|
||||
DoniTotali: nave.DoniTotali,
|
||||
DoniMancanti: nave.DoniMancanti,
|
||||
DoniConfermati: nave.DoniConfermati,
|
||||
tutor_namesurname: nave.tutor_namesurname,
|
||||
};
|
||||
|
||||
const risu = await NavePersistente.findOneAndUpdate({ _id: nave._id }, { $set: fieldsvalue }, { new: false });
|
||||
|
||||
nave._doc.rec = nave.rec;
|
||||
}
|
||||
}catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
return nave;
|
||||
|
||||
}
|
||||
|
||||
|
||||
const Nave = mongoose.model('Nave', NaveSchema);
|
||||
|
||||
module.exports = { Nave };
|
||||
|
||||
@@ -63,6 +63,9 @@ const NavePersistenteSchema = new mongoose.Schema({
|
||||
DoniConfermati: {
|
||||
type: Number,
|
||||
},
|
||||
DoniTotali: {
|
||||
type: Number,
|
||||
},
|
||||
note_bot: {
|
||||
type: String
|
||||
},
|
||||
@@ -97,7 +100,6 @@ function getQueryProj(myfilter) {
|
||||
received_gift: 1,
|
||||
date_received_gift: 1,
|
||||
num_tess: 1,
|
||||
indprimario: 1,
|
||||
parent_id: 1,
|
||||
riga: 1,
|
||||
col: 1,
|
||||
@@ -175,6 +177,8 @@ NavePersistenteSchema.statics.getListaNavi = function (idapp) {
|
||||
date_start: 1,
|
||||
provvisoria: 1,
|
||||
DoniConfermati: 1,
|
||||
DoniTotali: 1,
|
||||
DoniMancanti: 1,
|
||||
}
|
||||
).sort({ riga: 1, col: 1 });
|
||||
};
|
||||
|
||||
@@ -109,9 +109,6 @@ const UserSchema = new mongoose.Schema({
|
||||
date_reg: {
|
||||
type: Date,
|
||||
},
|
||||
date_temp_reg: {
|
||||
type: Date,
|
||||
},
|
||||
date_tokenforgot: {
|
||||
type: Date
|
||||
},
|
||||
@@ -139,6 +136,12 @@ const UserSchema = new mongoose.Schema({
|
||||
note: {
|
||||
type: String,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean
|
||||
},
|
||||
sospeso: {
|
||||
type: Boolean
|
||||
},
|
||||
profile: {
|
||||
img: {
|
||||
type: String
|
||||
@@ -198,6 +201,15 @@ const UserSchema = new mongoose.Schema({
|
||||
sex: {
|
||||
type: Number,
|
||||
},
|
||||
chisei: {
|
||||
type: String
|
||||
},
|
||||
iltuoimpegno: {
|
||||
type: String
|
||||
},
|
||||
come_aiutare: {
|
||||
type: String
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
@@ -317,7 +329,7 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
|
||||
// Check if with email:
|
||||
return User.findOne({ idapp, email: username.toLowerCase() })
|
||||
} else {
|
||||
return user
|
||||
return !user.deleted ? user : null
|
||||
}
|
||||
}).then(user => {
|
||||
if (!user)
|
||||
@@ -374,6 +386,8 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
deleted: 1,
|
||||
sospeso: 1,
|
||||
verified_email: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.saw_zoom_presentation': 1,
|
||||
@@ -921,18 +935,22 @@ UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
|
||||
UserSchema.statics.getUsersList = function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.find({ 'idapp': idapp }, {
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
verified_email: 1,
|
||||
made_gift: 1,
|
||||
perm: 1,
|
||||
email: 1,
|
||||
date_reg: 1,
|
||||
img: 1
|
||||
})
|
||||
|
||||
return User.find({
|
||||
'idapp': idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||
},
|
||||
{
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
verified_email: 1,
|
||||
made_gift: 1,
|
||||
perm: 1,
|
||||
email: 1,
|
||||
date_reg: 1,
|
||||
img: 1
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -1090,7 +1108,10 @@ UserSchema.statics.findByCellAndNameSurname = function (idapp, cell, name, surna
|
||||
UserSchema.statics.getUsersRegistered = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp };
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
@@ -1165,6 +1186,8 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
|
||||
surname: 1,
|
||||
username: 1,
|
||||
ind_order: 1,
|
||||
deleted: 1,
|
||||
sospeso: 1,
|
||||
});
|
||||
|
||||
|
||||
@@ -1177,38 +1200,48 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
|
||||
let num1inv = 0;
|
||||
let num2inv = 0;
|
||||
let numnoinlista = 0;
|
||||
let numeliminati = 0;
|
||||
let numsospesi = 0;
|
||||
|
||||
for (const user of arrusers) {
|
||||
user.numinvitati = await User.getnumInvitati(idapp, user.username);
|
||||
reg++;
|
||||
let mianave = await Nave.findOne({ idapp, ind_order: user.ind_order });
|
||||
let mialistaingresso = await ListaIngresso.findOne({ idapp, ind_order: user.ind_order });
|
||||
let trovato = false;
|
||||
if (!mianave) {
|
||||
mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.ind_order + '] [inv=' + user.numinvitati + ']'
|
||||
noninnave++;
|
||||
trovato = true;
|
||||
if (user.deleted) {
|
||||
numeliminati++;
|
||||
} else {
|
||||
innave++;
|
||||
}
|
||||
user.numinvitati = await User.getnumInvitati(idapp, user.username);
|
||||
reg++;
|
||||
let mianave = await Nave.findOne({ idapp, ind_order: user.ind_order });
|
||||
let mialistaingresso = await ListaIngresso.findOne({ idapp, ind_order: user.ind_order });
|
||||
let trovato = false;
|
||||
if (!mianave) {
|
||||
mystr += user.username + ' ' + user.name + ' ' + user.surname + ' [' + user.ind_order + '] [inv=' + user.numinvitati + ']'
|
||||
noninnave++;
|
||||
trovato = true;
|
||||
} else {
|
||||
innave++;
|
||||
}
|
||||
|
||||
if (!mialistaingresso) {
|
||||
mystr += ' NO IN LISTA INGRESSO!';
|
||||
trovato = true;
|
||||
numnoinlista++;
|
||||
}
|
||||
if (user.sospeso) {
|
||||
numsospesi++;
|
||||
}
|
||||
|
||||
if (trovato)
|
||||
mystr += tools.ACAPO;
|
||||
if (!mialistaingresso) {
|
||||
mystr += ' NO IN LISTA INGRESSO!';
|
||||
trovato = true;
|
||||
numnoinlista++;
|
||||
}
|
||||
|
||||
if (user.numinvitati === 0) {
|
||||
num0inv++;
|
||||
}
|
||||
if (user.numinvitati === 1) {
|
||||
num1inv++;
|
||||
}
|
||||
if (user.numinvitati >= 2) {
|
||||
num2inv++;
|
||||
if (trovato)
|
||||
mystr += tools.ACAPO;
|
||||
|
||||
if (user.numinvitati === 0) {
|
||||
num0inv++;
|
||||
}
|
||||
if (user.numinvitati === 1) {
|
||||
num1inv++;
|
||||
}
|
||||
if (user.numinvitati >= 2) {
|
||||
num2inv++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1220,6 +1253,8 @@ UserSchema.statics.visuUtentiNonInNavi = async function (idapp) {
|
||||
mystrstart += 'Presente in Nave: ' + innave + tools.ACAPO;
|
||||
mystrstart += 'Non in Nave: ' + noninnave + tools.ACAPO;
|
||||
mystrstart += 'Non in Lista Imbarco: ' + numnoinlista + tools.ACAPO;
|
||||
mystrstart += 'Usciti (Nascosti): ' + numeliminati + tools.ACAPO;
|
||||
mystrstart += 'Sospesi: ' + numsospesi + tools.ACAPO;
|
||||
|
||||
mystrstart += tools.ACAPO;
|
||||
|
||||
@@ -1240,7 +1275,11 @@ UserSchema.statics.getNumUsersQualified = async function (idapp, numinvitati) {
|
||||
UserSchema.statics.getEmailNotVerified = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, verified_email: false };
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
verified_email: false
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
@@ -1248,7 +1287,11 @@ UserSchema.statics.getEmailNotVerified = async function (idapp) {
|
||||
UserSchema.statics.getUsersTelegramAttivo = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.teleg_id': { $gt: 0 } };
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
'profile.teleg_id': { $gt: 0 }
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
@@ -1256,7 +1299,11 @@ UserSchema.statics.getUsersTelegramAttivo = async function (idapp) {
|
||||
UserSchema.statics.getUsersTelegramPending = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.teleg_checkcode': { $gt: 0 } };
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
'profile.teleg_checkcode': { $gt: 0 }
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
@@ -1264,7 +1311,11 @@ UserSchema.statics.getUsersTelegramPending = async function (idapp) {
|
||||
UserSchema.statics.getUsersZoom = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.saw_zoom_presentation': true };
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
'profile.saw_zoom_presentation': true
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
@@ -1272,7 +1323,11 @@ UserSchema.statics.getUsersZoom = async function (idapp) {
|
||||
UserSchema.statics.getSaw_and_Accepted = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED };
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
@@ -1282,6 +1337,7 @@ UserSchema.statics.getUsersDreams = async function (idapp) {
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
'profile.my_dream': { $exists: true },
|
||||
"$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] }
|
||||
};
|
||||
@@ -1294,15 +1350,19 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
|
||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
|
||||
|
||||
return await User.find({ idapp }, {
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
date_temp_reg: 1,
|
||||
date_reg: 1,
|
||||
ind_order: 1,
|
||||
'profile.nationality': 1,
|
||||
}).sort({ date_temp_reg: -1 }).limit(lastn).then((arr) => {
|
||||
return await User.find(
|
||||
{
|
||||
idapp,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||
},
|
||||
{
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
date_reg: 1,
|
||||
ind_order: 1,
|
||||
'profile.nationality': 1,
|
||||
}).sort({ date_reg: -1 }).limit(lastn).then((arr) => {
|
||||
//return JSON.stringify(arr)
|
||||
return arr
|
||||
});
|
||||
@@ -1362,10 +1422,10 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp, date_temp_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
|
||||
$match: { idapp, date_reg: { $gte: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_temp_reg" } }, count: { $sum: 1 } }
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
@@ -1379,10 +1439,10 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp, date_temp_reg: { $lt: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
|
||||
$match: { idapp, date_reg: { $lt: tools.IncDateNow(-(1000 * 60 * 60 * 24 * nrec)) } }
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_temp_reg" } }, count: { $sum: 1 } }
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
|
||||
Reference in New Issue
Block a user