Circuits...

Circuits Fido e Max Qta
Fixed error eslint: 7.0.0 is OK
This commit is contained in:
Paolo Arena
2022-09-11 11:45:33 +02:00
parent d262f94315
commit d62888083b
100 changed files with 3699 additions and 2774 deletions

View File

@@ -1,5 +1,5 @@
const bcrypt = require('bcryptjs');
const mongoose = require('mongoose').set('debug', false);
const mongoose = require('mongoose').set('debug', process.env.DEBUG);
const validator = require('validator');
const jwt = require('jsonwebtoken');
const _ = require('lodash');
@@ -470,7 +470,7 @@ UserSchema.statics.setZoomPresenza = async function(idapp, id, presenza) {
allData.precDataUser = await User.getInfoUser(idapp,
allData.myuser.username);
return User.findByIdAndUpdate(id,
return await User.findByIdAndUpdate(id,
{$set: {'profile.saw_zoom_presentation': presenza}}).then((rec) => {
if (presenza) {
const messaggio = tools.get__('ZOOM_CONFERMATO');
@@ -663,15 +663,15 @@ UserSchema.statics.findByUsername = async function(idapp, username, alsoemail, o
//++TODO: Set only the necessary fields to get in memory
return User.findOne({
return await User.findOne({
idapp: idapp,
username: {$regex: regexusername},
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).then((ris) => {
}).then(async (ris) => {
if ((!ris) && (alsoemail)) {
regexemail = new RegExp(['^', username.toLowerCase(), '$'].join(''), 'i');
return User.findOne({
return await User.findOne({
'idapp': idapp,
'email': {$regex: regexemail},
$or: [
@@ -1009,7 +1009,7 @@ UserSchema.statics.setaportador_solidario = async function(
UserSchema.statics.setVerifiedByAportadorToALL = async function() {
return User.updateMany({}, {$set: {'verified_by_aportador': true}},
return await User.updateMany({}, {$set: {'verified_by_aportador': true}},
{new: false});
};
@@ -1051,7 +1051,7 @@ UserSchema.statics.isUserQualified9 = async function(idapp, username) {
UserSchema.statics.getnumPaymentOk = function (idapp) {
const User = this;
return User.count({
return await User.count({
idapp,
$and: [
{
@@ -1146,7 +1146,7 @@ UserSchema.statics.createNewRequestPwd = function(idapp, email) {
toString();
user.date_tokenforgot = new Date();
user.lasttimeonline = new Date();
return user.save().then(async () => {
return await user.save().then(async () => {
await sendemail.sendEmail_RequestNewPassword(user.lang, user, user.email, user.idapp, user.tokenforgot);
return true;
@@ -1172,7 +1172,7 @@ UserSchema.statics.createNewRequestPwdByUsernameAndGetLink = async function(idap
user.date_tokenforgot = new Date();
user.lasttimeonline = new Date();
return user.save().then(() => {
return await user.save().then(() => {
return tools.getlinkRequestNewPassword(idapp, user.email, user.tokenforgot);
});
}
@@ -1294,7 +1294,7 @@ UserSchema.methods.removeToken = function(token) {
UserSchema.statics.getEmailByUsername = async function(idapp, username) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).then((arrrec) => {
@@ -1307,7 +1307,7 @@ UserSchema.statics.getEmailByUsername = async function(idapp, username) {
UserSchema.statics.getUsernameById = async function(idapp, id) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, _id: id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {username: 1}).then((myuser) => {
@@ -1340,7 +1340,7 @@ UserSchema.statics.isMyFriend = async function(idapp, username, myusername) {
const myfriends = await User.getUsernameFriendsByUsername(idapp, myusername);
if (myfriends) {
return myfriends.includes(username);
return await myfriends.includes(username);
} else {
return false;
}
@@ -1576,7 +1576,7 @@ UserSchema.statics.getArrUsernameFromFieldByUsername = async function(
UserSchema.statics.getUsernameReqFriendsByUsername = async function(
idapp, username) {
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
'req_friends');
};
@@ -1584,7 +1584,7 @@ UserSchema.statics.getUsernameReqFriendsByUsername = async function(
UserSchema.statics.getUsernameFriendsByUsername = async function(
idapp, username) {
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
'friends');
};
@@ -1592,14 +1592,14 @@ UserSchema.statics.getUsernameFriendsByUsername = async function(
UserSchema.statics.getUsernameGroupsByUsername = async function(
idapp, username) {
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
'mygroups');
};
UserSchema.statics.getUsernameCircuitsByUsername = async function(
idapp, username) {
return this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
return await this.getArrUsernameFromFieldByUsername(idapp, username, 'profile',
'mycircuits');
};
@@ -1607,39 +1607,39 @@ UserSchema.statics.getUsernameCircuitsByUsername = async function(
// Rimuovo l'Amicizia
UserSchema.statics.removeFriend = async function(
idapp, username, usernameDest) {
return User.updateOne({idapp, username},
return await User.updateOne({idapp, username},
{$pull: {'profile.friends': {username: {$in: [usernameDest]}}}});
};
// Rimuovo il Gruppo
UserSchema.statics.removeFromMyGroups = async function(
idapp, username, groupnameDest) {
return User.updateOne({idapp, username},
return await User.updateOne({idapp, username},
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
};
// Rimuovo il Gruppo
UserSchema.statics.removeFromCircuits = async function(idapp, username, circuitname) {
return User.updateOne({idapp, username},
return await User.updateOne({idapp, username},
{$pull: {'profile.mycircuits': {circuitname: {$in: [circuitname]}}}});
};
// Rimuovo il Gruppo per Tutti gli Utenti
UserSchema.statics.removeAllUsersFromMyGroups = async function(idapp, groupnameDest) {
return User.updateMany({idapp},
return await User.updateMany({idapp},
{$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}});
};
// Rimuovo il Circuito per Tutti gli Utenti
UserSchema.statics.removeAllUsersFromMyCircuits = async function(idapp, circuitname) {
return User.updateMany({idapp},
return await User.updateMany({idapp},
{$pull: {'profile.mycircuits': {circuitname: {$in: [circuitname]}}}});
};
// Rimuovo la Richiesta di Amicizia
UserSchema.statics.removeReqFriend = async function(
idapp, username, usernameDest) {
return User.updateOne({idapp, username: username},
return await User.updateOne({idapp, username: username},
{$pull: {'profile.req_friends': {username: {$in: [usernameDest]}}}});
};
@@ -1665,7 +1665,7 @@ UserSchema.statics.setFriendsCmd = async function(req, idapp, usernameOrig, user
await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest,
shared_consts.FRIENDSCMD.SETFRIEND, value);
return User.updateOne({idapp, username: usernameDest},
return await User.updateOne({idapp, username: usernameDest},
{$set: {verified_by_aportador: value, trust_modified: new Date()}},
{new: false});
@@ -1890,7 +1890,7 @@ UserSchema.statics.setFriendsCmd = async function(req, idapp, usernameOrig, user
UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupnameDest) {
// Controllo se è stato già inserito
return User.findOne({
return await User.findOne({
idapp,
username: usernameOrig,
'profile.mygroups': {
@@ -1903,7 +1903,7 @@ UserSchema.statics.ifAlreadyInGroup = async function(idapp, usernameOrig, groupn
UserSchema.statics.ifAlreadyInCircuit = async function(idapp, usernameOrig, circuitname) {
// Controllo se è stato già inserito
return User.findOne({
return await User.findOne({
idapp,
username: usernameOrig,
'profile.mycircuits': {
@@ -1915,7 +1915,7 @@ UserSchema.statics.ifAlreadyInCircuit = async function(idapp, usernameOrig, circ
UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
// Controllo se è stato già inserito
return User.countDocuments({
return await User.countDocuments({
idapp,
'profile.mygroups': {
$elemMatch: {groupname: {$eq: groupnameDest}},
@@ -1927,7 +1927,7 @@ UserSchema.statics.countUsersInGroup = async function(idapp, groupnameDest) {
UserSchema.statics.countUsersInCircuit = async function(idapp, circuitname) {
// Controllo se è stato già inserito
return User.countDocuments({
return await User.countDocuments({
idapp,
'profile.mycircuits': {
$elemMatch: {circuitname: {$eq: circuitname}},
@@ -2190,13 +2190,13 @@ UserSchema.statics.setCircuitCmd = async function(idapp, usernameOrig, circuitna
} else if (cmd === shared_consts.CIRCUITCMD.REMOVEADMIN) {
ris = await Circuit.removeAdminOfCircuit(idapp, usernameOrig, circuitname); // Rimuovo la richiesta di entrare nel gruppo
w
// Invia una notifica alla persona
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REQ) {
// Invia una notifica di moneta alla persona
await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
ris = await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
} else if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
ris = await Circuit.sendCoins(idapp, usernameOrig, extrarec);
@@ -2296,7 +2296,7 @@ UserSchema.statics.getInfoFriendByUsername = async function(idapp, username) {
const whatToShow = getWhatToShow(idapp, username);
return User.findOne({
return await User.findOne({
idapp,
username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
@@ -2309,7 +2309,7 @@ UserSchema.statics.getInfoAskFriendByUsername = async function(
const whatToShow = getWhatToShow_Unknown(idapp, username);
return User.findOne({
return await User.findOne({
idapp,
username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
@@ -2321,7 +2321,7 @@ UserSchema.statics.getAskedFriendsByUsername = async function(idapp, username) {
const whatToShow_Unknown = getWhatToShow_Unknown(idapp, username);
return User.find({
return await User.find({
idapp,
'profile.req_friends': {
$elemMatch: {username: {$eq: username}},
@@ -2402,7 +2402,7 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function(
idapp, username) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).then((rec) => {
@@ -2415,7 +2415,7 @@ UserSchema.statics.getAportadorSolidarioByUsername = async function(
UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, 'profile.teleg_id': teleg_id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).lean().then((rec) => {
@@ -2428,7 +2428,7 @@ UserSchema.statics.UserByIdTelegram = async function(idapp, teleg_id) {
UserSchema.statics.UsersByIdTelegram = async function(idapp, teleg_id) {
const User = this;
return User.find({
return await User.find({
idapp, 'profile.teleg_id': teleg_id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}).lean().then((rec) => {
@@ -2445,7 +2445,7 @@ UserSchema.statics.setPicProfile = async function(idapp, username, imgpic) {
'profile.img': imgpic,
};
return User.findOneAndUpdate({
return await User.findOneAndUpdate({
idapp, username,
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
return !!record;
@@ -2456,7 +2456,7 @@ UserSchema.statics.setPicProfile = async function(idapp, username, imgpic) {
UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {'profile.teleg_id': 1}).lean().then((rec) => {
@@ -2469,7 +2469,7 @@ UserSchema.statics.TelegIdByUsername = async function(idapp, username) {
UserSchema.statics.TelegIdById = async function(idapp, id) {
const User = this;
return User.findOne({
return await User.findOne({
idapp,
_id: id,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
@@ -2481,7 +2481,7 @@ UserSchema.statics.TelegIdById = async function(idapp, id) {
};
UserSchema.statics.notAsk_VerifByUsername = async function(idapp, username) {
return User.findOne({
return await User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {'notask_verif': 1}).lean().then((rec) => {
@@ -2500,7 +2500,7 @@ UserSchema.statics.SetTelegramCheckCode = async function(
'profile.teleg_checkcode': teleg_checkcode,
};
return User.findOneAndUpdate({
return await User.findOneAndUpdate({
_id: id,
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
return !!record;
@@ -2515,7 +2515,7 @@ UserSchema.statics.NonVoglioImbarcarmi = async function(idapp, username) {
non_voglio_imbarcarmi: true,
};
return User.findOneAndUpdate({
return await User.findOneAndUpdate({
idapp,
username,
}, {$set: fields_to_update}, {new: false}).then((record) => {
@@ -2533,7 +2533,7 @@ UserSchema.statics.SetTelegramIdSuccess = async function(idapp, id, teleg_id) {
'profile.teleg_checkcode': 0,
};
return User.findOneAndUpdate({
return await User.findOneAndUpdate({
idapp,
_id: id,
}, {$set: fields_to_update}, {new: false}).lean().then((record) => {
@@ -2560,7 +2560,7 @@ UserSchema.statics.setUsernameTelegram = async function(
'profile.lastname_telegram': lastname_telegram,
};
return User.findOneAndUpdate({
return await User.findOneAndUpdate({
idapp,
_id: id,
}, {$set: fields_to_update}, {new: false}).then((record) => {
@@ -2576,7 +2576,7 @@ UserSchema.statics.SetLang = async function(idapp, id, lang) {
lang,
};
return User.findOneAndUpdate({
return await User.findOneAndUpdate({
_id: id,
}, {$set: fields_to_update}, {new: false}).then((record) => {
return record;
@@ -2608,7 +2608,7 @@ UserSchema.statics.getNameSurnameByUsername = async function(
idapp, username, reale = false) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {username: 1, name: 1, surname: 1}).then((rec) => {
@@ -2636,7 +2636,7 @@ UserSchema.statics.getIdByUsername = async function(idapp, username) {
let regexp = new RegExp(`^${username}$`, 'i');
return User.findOne({
return await User.findOne({
idapp,
username: {$regex: regexp},
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
@@ -2652,7 +2652,7 @@ UserSchema.statics.getRealUsernameByUsername = async function(idapp, username) {
let regexp = new RegExp(`^${username}$`, 'i');
return User.findOne({
return await User.findOne({
idapp,
username:
{$regex: regexp},
@@ -2667,7 +2667,7 @@ UserSchema.statics.getRealUsernameByUsername = async function(idapp, username) {
UserSchema.statics.getRecLangAndIdByUsername = async function(idapp, username) {
const User = this;
return User.findOne({
return await User.findOne({
idapp, username,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
}, {lang: 1, _id: 1}).then((rec) => {
@@ -2680,7 +2680,7 @@ UserSchema.statics.getRecLangAndIdByUsername = async function(idapp, username) {
UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
const User = this;
return User.findOne({
return await User.findOne({
idapp,
_id: userId,
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
@@ -2694,7 +2694,7 @@ UserSchema.statics.getNameSurnameById = async function(idapp, userId) {
UserSchema.statics.getusersManagers = async function(idapp) {
const User = this;
return User.find({idapp, 'profile.manage_telegram': true},
return await User.find({idapp, 'profile.manage_telegram': true},
{username: 1, 'profile.teleg_id': 1, perm: 1}).then((arrrec) => {
return (!!arrrec) ? arrrec : null;
}).catch((e) => {
@@ -2705,7 +2705,7 @@ UserSchema.statics.getusersManagers = async function(idapp) {
UserSchema.statics.getusersRespList = async function(idapp) {
const User = this;
return User.find({idapp, 'profile.resplist': true},
return await User.find({idapp, 'profile.resplist': true},
{_id: 1, username: 1, name: 1, surname: 1}).then((arrrec) => {
return (!!arrrec) ? arrrec : null;
}).catch((e) => {
@@ -2716,7 +2716,7 @@ UserSchema.statics.getusersRespList = async function(idapp) {
UserSchema.statics.getusersWorkersList = async function(idapp) {
const User = this;
return User.find({idapp, 'profile.workerslist': true},
return await User.find({idapp, 'profile.workerslist': true},
{_id: 1, username: 1, name: 1, surname: 1}).then((arrrec) => {
return (!!arrrec) ? arrrec : null;
}).catch((e) => {
@@ -2727,7 +2727,7 @@ UserSchema.statics.getusersWorkersList = async function(idapp) {
UserSchema.statics.getusersManagersAndZoomeri = async function(idapp) {
const User = this;
return User.find(
return await User.find(
{
idapp,
or: [
@@ -2754,7 +2754,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
const User = this;
if (!!username) {
return User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).lean();
return await User.find({idapp, username, 'profile.teleg_id': {$gt: 0}}).lean();
then((arrrec) => {
return (!!arrrec) ? arrrec : null;
}).
@@ -2762,7 +2762,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
console.error('getUsersTelegALL', e);
});
} else {
return User.find({idapp, 'profile.teleg_id': {$gt: 0}}).
return await User.find({idapp, 'profile.teleg_id': {$gt: 0}}).
lean().
then((arrrec) => {
return (!!arrrec) ? arrrec : null;
@@ -2777,7 +2777,7 @@ UserSchema.statics.getUsersTelegALL = async function(idapp, username) {
UserSchema.statics.isManagerByIdTeleg = async function(idapp, idtelegram) {
const User = this;
return User.findOne({
return await User.findOne({
idapp,
'profile.manage_telegram': true,
'profile.teleg_id': idtelegram,
@@ -2792,7 +2792,7 @@ UserSchema.statics.isManagerByIdTeleg = async function(idapp, idtelegram) {
UserSchema.statics.isAdminByIdTeleg = async function(idapp, idtelegram) {
const User = this;
return User.findOne({
return await User.findOne({
idapp,
username: 'paoloar77',
'profile.manage_telegram': true,
@@ -2884,14 +2884,14 @@ UserSchema.statics.findAllIdApp = async function(idapp) {
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
};
return User.find(myfind, (err, arrrec) => {
return await User.find(myfind, (err, arrrec) => {
return arrrec;
});
};
UserSchema.statics.DuplicateAllRecords = async function(idapporig, idappdest) {
return tools.DuplicateAllRecords(this, idapporig, idappdest);
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
};
@@ -3005,7 +3005,7 @@ UserSchema.statics.getUsersRegistered = async function(idapp) {
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersOnLineToday = async function(idapp) {
@@ -3020,7 +3020,7 @@ UserSchema.statics.getUsersOnLineToday = async function(idapp) {
lasttimeonline: {$gt: starttoday},
};
return User.count(myfind);
return await User.count(myfind);
};
/*
@@ -3089,7 +3089,7 @@ UserSchema.statics.getEmailNotVerified = async function(idapp) {
verified_email: false,
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
@@ -3101,7 +3101,7 @@ UserSchema.statics.getUsersTelegramAttivo = async function(idapp) {
'profile.teleg_id': {$gt: 0},
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersAutorizzati = async function(idapp) {
@@ -3114,7 +3114,7 @@ UserSchema.statics.getUsersAutorizzati = async function(idapp) {
verified_by_aportador: true,
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersAutorizzare = async function(idapp) {
@@ -3127,7 +3127,7 @@ UserSchema.statics.getUsersAutorizzare = async function(idapp) {
verified_by_aportador: {$exists: false},
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersTelegramPending = async function(idapp) {
@@ -3139,7 +3139,7 @@ UserSchema.statics.getUsersTelegramPending = async function(idapp) {
'profile.teleg_checkcode': {$gt: 0},
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getNumUsers = async function(idapp) {
@@ -3150,7 +3150,7 @@ UserSchema.statics.getNumUsers = async function(idapp) {
$or: [{deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}],
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersZoom = async function(idapp) {
@@ -3162,7 +3162,7 @@ UserSchema.statics.getUsersZoom = async function(idapp) {
'profile.saw_zoom_presentation': true,
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersResidenti = async function(idapp) {
@@ -3174,7 +3174,7 @@ UserSchema.statics.getUsersResidenti = async function(idapp) {
'profile.socioresidente': {$exists: true, $eq: true},
};
return User.find(myfind, {username: 1, name: 1, surname: 1});
return await User.find(myfind, {username: 1, name: 1, surname: 1});
};
UserSchema.statics.getSaw_and_Accepted = async function(idapp) {
@@ -3186,7 +3186,7 @@ UserSchema.statics.getSaw_and_Accepted = async function(idapp) {
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED,
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getUsersDreams = async function(idapp) {
@@ -3199,7 +3199,7 @@ UserSchema.statics.getUsersDreams = async function(idapp) {
'$expr': {'$gt': [{'$strLenCP': '$profile.my_dream'}, 10]},
};
return User.count(myfind);
return await User.count(myfind);
};
UserSchema.statics.getLastUsers = async function(idapp) {
@@ -3207,7 +3207,7 @@ UserSchema.statics.getLastUsers = async function(idapp) {
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 5);
return User.find(
return await User.find(
{
idapp,
$or: [
@@ -3231,7 +3231,7 @@ UserSchema.statics.getLastUsers = async function(idapp) {
UserSchema.statics.checkUser = async function(idapp, username) {
const User = this;
return User.findOne({idapp, username}, {
return await User.findOne({idapp, username}, {
verified_email: 1,
verified_by_aportador: 1,
notask_verif: 1,
@@ -3301,7 +3301,7 @@ UserSchema.statics.getDistinctNationalityQuery = function(idapp) {
UserSchema.statics.findAllDistinctNationality = async function(idapp) {
const User = this;
return User.aggregate(User.getDistinctNationalityQuery(idapp)).then(ris => {
return await User.aggregate(User.getDistinctNationalityQuery(idapp)).then(ris => {
// console.table(ris);
return ris;
});
@@ -3403,7 +3403,7 @@ UserSchema.statics.getnumRegNDays = function(idapp, nrec) {
UserSchema.statics.calcnumRegUntilDay = async function(idapp) {
const User = this;
return User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
return await User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
return arr.reduce((sum, rec) => sum + rec.count, 0);
});
@@ -3412,7 +3412,7 @@ UserSchema.statics.calcnumRegUntilDay = async function(idapp) {
UserSchema.statics.calcRegDaily = async function(idapp) {
const User = this;
return User.aggregate(User.getUsersRegDaily(idapp, 60)).then(ris => {
return await User.aggregate(User.getUsersRegDaily(idapp, 60)).then(ris => {
// console.table(ris);
return ris;
});
@@ -3421,7 +3421,7 @@ UserSchema.statics.calcRegDaily = async function(idapp) {
UserSchema.statics.calcRegWeekly = async function(idapp) {
const User = this;
return User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)).then(ris => {
return await User.aggregate(User.getUsersRegWeekly(idapp, 20 * 7)).then(ris => {
// console.table(ris);
return ris.slice(0, -1);
});