fix: non riuscivi ad acquistare i RIS al gruppo
- lista linkREG
This commit is contained in:
@@ -435,6 +435,9 @@ const UserSchema = new mongoose.Schema({
|
||||
lastdate_reqRis: {
|
||||
type: Date,
|
||||
},
|
||||
lastdate_LinkReg: {
|
||||
type: Date,
|
||||
},
|
||||
notifs: [
|
||||
{
|
||||
_id: false,
|
||||
@@ -4878,6 +4881,15 @@ UserSchema.statics.getReceiveRISUsers = async function (idapp) {
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
UserSchema.statics.getListLinkReg = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.aggregate(User.getQueryListLinkReg(idapp, 8)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.checkUser = async function (idapp, username) {
|
||||
@@ -5423,6 +5435,93 @@ UserSchema.statics.getQueryReceiveRISUsers = function (idapp, hours) {
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getQueryListLinkReg = function (idapp, hours) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
'profile.lastdate_LinkReg': { $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_linkReg': -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_linkReg': 1,
|
||||
'profile.mycircuits': 1,
|
||||
date_reg: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.note': 1,
|
||||
'profile.da_contattare': 1,
|
||||
perm: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
|
||||
|
||||
const query = [
|
||||
@@ -6220,6 +6319,17 @@ UserSchema.statics.setReceiveRis = async function (idapp, username) {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
UserSchema.statics.setLinkReg = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
idapp, username,
|
||||
},
|
||||
{ $set: { 'profile.lastdate_LinkReg': new Date() } }, { new: false }).lean().then((record) => {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
|
||||
Reference in New Issue
Block a user