Aggiornamenti
This commit is contained in:
@@ -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