- Invia Ris a e Ricevi Ris
- Tutorial Guidato Passi da Compiere - Provincia in cui vivi - Policy aggiornata
This commit is contained in:
@@ -398,7 +398,12 @@ const UserSchema = new mongoose.Schema({
|
||||
circuitname: { type: String },
|
||||
date: { type: Date },
|
||||
}],
|
||||
|
||||
last_circuitpath: {
|
||||
type: String,
|
||||
},
|
||||
lastdate_reqRis: {
|
||||
type: Date,
|
||||
},
|
||||
notifs: [
|
||||
{
|
||||
_id: false,
|
||||
@@ -433,6 +438,12 @@ const UserSchema = new mongoose.Schema({
|
||||
type: String,
|
||||
trim: true,
|
||||
},
|
||||
stepTutorial: {
|
||||
type: Number,
|
||||
},
|
||||
noNameSurname: {
|
||||
type: Boolean,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3764,6 +3775,7 @@ UserSchema.statics.getLastOnlineUsers = async function (idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
date_reg: 1,
|
||||
'profile.img': 1,
|
||||
index: 1,
|
||||
}).sort({ lasttimeonline: -1 }).limit(lastn).then((arr) => {
|
||||
@@ -3790,6 +3802,7 @@ UserSchema.statics.getLastSharedLink = async function (idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
date_reg: 1,
|
||||
'profile.img': 1,
|
||||
index: 1,
|
||||
}).sort({ date_tokenreg: -1 }).limit(lastn).then((arr) => {
|
||||
@@ -3822,6 +3835,16 @@ UserSchema.statics.getBestStretteDiManoUsers = async function (idapp) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getReceiveRISUsers = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.aggregate(User.getQueryReceiveRISUsers(idapp, 8)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.checkUser = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
@@ -4020,8 +4043,10 @@ UserSchema.statics.getQueryUsersDiffusori = function (idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
date_reg: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
'profile.mycircuits': 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -4110,6 +4135,92 @@ UserSchema.statics.getQueryUsersStretteDiMano = function (idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
date_reg: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.mycircuits': 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getQueryReceiveRISUsers = function (idapp, hours) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
'profile.lastdate_reqRis': { $gte: tools.IncDateNow(-(1000 * 60 * 60 * hours)) },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: "$username",
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $sort: { 'profile.lastdate_reqRis': -1 } },
|
||||
{ $limit: 30 },
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
username: "$_id",
|
||||
idapp,
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$username",
|
||||
"$username",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{ $unwind: "$user" },
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: ["$user", "$$ROOT"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
count: 1,
|
||||
aportador_solidario: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.lastdate_reqRis': 1,
|
||||
'profile.mycircuits': 1,
|
||||
date_reg: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
'profile.handshake': 1,
|
||||
@@ -4184,7 +4295,7 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
|
||||
UserSchema.statics.calcnumRegUntilDay = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.aggregate(User.getnumRegNDays(idapp, 30)).then((arr) => {
|
||||
return await User.aggregate(User.getnumRegNDays(idapp, 60)).then((arr) => {
|
||||
return arr.reduce((sum, rec) => sum + rec.count, 0);
|
||||
});
|
||||
|
||||
@@ -4622,6 +4733,27 @@ UserSchema.statics.tooManyReqPassword = async function (idapp, email, set) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.setLastCircuitOpened = async function (idapp, username, circuitpath) {
|
||||
|
||||
try {
|
||||
return await User.findOneAndUpdate({ idapp, username }, { $set: { 'profile.last_circuitpath': circuitpath } });
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.setReceiveRis = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
idapp, username,
|
||||
},
|
||||
{ $set: { 'profile.lastdate_reqRis': new Date() } }, { new: false }).lean().then((record) => {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
const User = this;
|
||||
|
||||
Reference in New Issue
Block a user