- Chart Maps Nationality
- Username lowercase - Statistics - Telegram
This commit is contained in:
@@ -286,7 +286,7 @@ UserSchema.statics.findByCredentials = function (idapp, username, password) {
|
||||
return User.findOne({ idapp, username: username }).then((user) => {
|
||||
if (!user) {
|
||||
// Check if with email:
|
||||
return User.findOne({ idapp, email: username })
|
||||
return User.findOne({ idapp, email: username.toLowerCase() })
|
||||
} else {
|
||||
return user
|
||||
}
|
||||
@@ -416,6 +416,12 @@ UserSchema.statics.findByEmail = function (idapp, email) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUser = function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.findOne({ idapp }).sort({ ind_order: -1 })
|
||||
};
|
||||
|
||||
UserSchema.pre('save', function (next) {
|
||||
const user = this;
|
||||
|
||||
@@ -548,7 +554,28 @@ UserSchema.statics.getUsersTelegALL = async function (idapp) {
|
||||
UserSchema.statics.isManagerByIdTeleg = async function (idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, 'profile.manage_telegram': true, 'profile.teleg_id': idtelegram }, { 'profile.teleg_id': 1 })
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
'profile.manage_telegram': true,
|
||||
'profile.teleg_id': idtelegram
|
||||
}, { 'profile.teleg_id': 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec && rec.profile.teleg_id === idtelegram);
|
||||
}).catch((e) => {
|
||||
console.error('getusersManagers', e);
|
||||
return false
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
'username': 'paoloar77',
|
||||
'profile.manage_telegram': true,
|
||||
'profile.teleg_id': idtelegram
|
||||
}, { 'profile.teleg_id': 1 })
|
||||
.then((rec) => {
|
||||
return (!!rec && rec.profile.teleg_id === idtelegram);
|
||||
}).catch((e) => {
|
||||
@@ -607,7 +634,7 @@ UserSchema.statics.getUsersListByParams = function (params) {
|
||||
*/
|
||||
|
||||
UserSchema.statics.getFieldsForSearch = function () {
|
||||
return ['name', 'surname', 'email', 'profile.cell', 'profile.email_paypal', 'profile.username_telegram', 'aportador_solidario']
|
||||
return ['username', 'name', 'surname', 'email', 'profile.cell', 'profile.email_paypal', 'profile.username_telegram', 'aportador_solidario']
|
||||
};
|
||||
|
||||
UserSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
@@ -682,12 +709,59 @@ UserSchema.statics.getUsersRegistered = async function (idapp) {
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getEmailNotVerified = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, verified_email: false };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramAttivo = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.teleg_id': { $gt: 0 } };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersTelegramPending = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.teleg_checkcode': { $gt: 0 } };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersZoom = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = { idapp, 'profile.saw_zoom_presentation': true };
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersDreams = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const myfind = {
|
||||
idapp,
|
||||
'profile.my_dream': { $exists: true },
|
||||
"$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] }
|
||||
};
|
||||
|
||||
return await User.count(myfind);
|
||||
};
|
||||
|
||||
UserSchema.statics.getLastUsers = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
|
||||
|
||||
return await User.find({ idapp }).sort({ date_temp_reg: -1 }).limit(lastn);
|
||||
return await User.find({ idapp }).sort({ date_temp_reg: -1 }).limit(lastn).then((arr) => {
|
||||
//return JSON.stringify(arr)
|
||||
return arr
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
@@ -698,6 +772,8 @@ UserSchema.statics.checkUser = async function (idapp, username) {
|
||||
verified_email: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.teleg_checkcode': 1,
|
||||
}).then((rec) => {
|
||||
return JSON.stringify(rec)
|
||||
});
|
||||
|
||||
};
|
||||
@@ -712,8 +788,61 @@ UserSchema.statics.calculateStat = async function (idapp, username) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersNationalityQuery = function (idapp) {
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp }
|
||||
},
|
||||
{
|
||||
$group: { _id: "$profile.nationality", count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { count: -1 }
|
||||
}
|
||||
];
|
||||
return query
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.findAllDistinctNationality = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getUsersNationalityQuery(idapp))
|
||||
.then(ris => {
|
||||
// console.table(ris);
|
||||
return JSON.stringify(ris);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
|
||||
const query = [
|
||||
{
|
||||
$match: { idapp }
|
||||
},
|
||||
{
|
||||
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_temp_reg" } }, count: { $sum: 1 } }
|
||||
},
|
||||
{
|
||||
$sort: { _id: 1 }
|
||||
},
|
||||
{
|
||||
$limit: nrec
|
||||
}
|
||||
];
|
||||
return query
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.calcRegDaily = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.aggregate(User.getUsersRegDaily(idapp, 30))
|
||||
.then(ris => {
|
||||
// console.table(ris);
|
||||
return JSON.stringify(ris);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
if (tools.INITDB_FIRSTIME) {
|
||||
console.log(' createIndex User Index...');
|
||||
|
||||
Reference in New Issue
Block a user