- Statistiche

- Menu e Sottomenu
- Lista ultimi Movimenti
This commit is contained in:
Surya Paolo
2024-09-26 02:14:33 +02:00
parent ca519baad4
commit ce51c87365
13 changed files with 45558 additions and 64 deletions

View File

@@ -4263,6 +4263,25 @@ UserSchema.statics.getUsersOnLineToday = async function (idapp) {
return await User.countDocuments(myfind);
};
UserSchema.statics.getUsersOnLineActive = async function (idapp) {
const User = this;
const numgiorni_attivi = await Settings.getValDbSettings(idapp, 'SHOW_LAST_ACTIVE_USERS', 90);
let daytocheck = new Date();
daytocheck.setDate(daytocheck.getDate() - numgiorni_attivi);
daytocheck.setHours(0, 0, 0, 0);
const myfind = {
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
lasttimeonline: { $gt: daytocheck },
};
return await User.countDocuments(myfind);
};
/*
UserSchema.statics.getUsersQualified = async function (idapp, numinvitati) {
const User = this;
@@ -4465,7 +4484,7 @@ UserSchema.statics.getLastUsers = async function (idapp) {
date_reg: 1,
index: 1,
'profile.nationality': 1,
}).sort({ date_reg: -1 }).limit(lastn).then((arr) => {
}).sort({ date_reg: -1 }).limit(lastn).lean().then((arr) => {
//return JSON.stringify(arr)
return arr;
});
@@ -4494,7 +4513,7 @@ UserSchema.statics.getLastOnlineUsers = async function (idapp) {
idMyGroup: 1,
'profile.img': 1,
index: 1,
}).sort({ lasttimeonline: -1 }).limit(lastn).then((arr) => {
}).sort({ lasttimeonline: -1 }).limit(lastn).lean().then((arr) => {
//return JSON.stringify(arr)
return arr;
});
@@ -4523,7 +4542,7 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
date_reg: 1,
'profile.img': 1,
index: 1,
}).sort({ date_tokenreg: -1 }).limit(lastn).then((arr) => {
}).sort({ date_tokenreg: -1 }).limit(lastn).lean().then((arr) => {
return arr;
});
@@ -4534,7 +4553,7 @@ UserSchema.statics.getDiffusoriUsers = async function (idapp) {
const lastn = 10;
return await User.aggregate(User.getQueryUsersDiffusori(idapp)).then(ris => {
return await User.aggregate(await User.getQueryUsersDiffusori(idapp)).then(ris => {
// console.table(ris);
return ris;
});
@@ -4546,7 +4565,7 @@ UserSchema.statics.getBestStretteDiManoUsers = async function (idapp) {
const lastn = 10;
return await User.aggregate(User.getQueryUsersStretteDiMano(idapp)).then(ris => {
return await User.aggregate(await User.getQueryUsersStretteDiMano(idapp)).then(ris => {
// console.table(ris);
return ris;
});
@@ -4715,7 +4734,9 @@ UserSchema.statics.getUsersRegDailyAverage = function (idapp, nrec) {
return query;
};
UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
UserSchema.statics.getQueryUsersDiffusori = async function (idapp) {
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 20);
const query = [
{
@@ -4752,7 +4773,7 @@ UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
count: -1,
},
},
{ $limit: 20 },
{ $limit: lastn },
{
$lookup: {
from: "users",
@@ -4805,15 +4826,17 @@ UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
date_reg: 1,
idapp: 1,
"profile.img": 1,
'profile.mycircuits': 1,
'profile.handshake': 1,
// 'profile.mycircuits': 1,
// 'profile.handshake': 1,
},
},
];
return query;
};
UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
UserSchema.statics.getQueryUsersStretteDiMano = async function (idapp) {
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 20);
const query = [
{
@@ -4845,7 +4868,7 @@ UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
}
},
{ $sort: { count: -1 } },
{ $limit: 20 },
{ $limit: lastn },
{
$lookup: {
from: "users",
@@ -4898,8 +4921,8 @@ UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
date_reg: 1,
idapp: 1,
"profile.img": 1,
'profile.handshake': 1,
'profile.mycircuits': 1,
// 'profile.handshake': 1,
// 'profile.mycircuits': 1,
},
},
];
@@ -5870,6 +5893,30 @@ UserSchema.statics.renameCircuitName = async function (idapp, oldcircuitname, ne
return await User.updateMany({ idapp, 'profile.mycircuits.circuitname': oldcircuitname }, { $set: { 'profile.mycircuits.$.circuitname': newcircuitname } });
};
UserSchema.statics.getnumAnnunci = async function (idapp) {
const { MySkill } = require('../models/myskill');
const { MyGood } = require('../models/mygood');
const { MyBacheca } = require('../models/mybacheca');
const { MyHosp } = require('../models/myhosp');
let num = 0;
try {
num += await MySkill.countDocuments({ idapp });
num += await MyGood.countDocuments({ idapp });
num += await MyBacheca.countDocuments({ idapp });
num += await MyHosp.countDocuments({ idapp });
} catch (e) {
}
return num;
};
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
const User = this;