Lista Richieste e Rifiutati dei Conti Collettivi

This commit is contained in:
Surya Paolo
2023-02-16 20:13:38 +01:00
parent a81300e13d
commit 874114942a
6 changed files with 138 additions and 15 deletions

View File

@@ -1756,6 +1756,37 @@ module.exports = {
return myquery;
},
getGroupnameLookupPipeLine(params, proj) {
let myquery = [
{
$lookup: {
from: params.lk_tab,
let: { groupname: '$' + params.lk_LF, idapp: params.idapp },
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{ $eq: ['$' + params.lk_FF, '$$' + params.lk_FF] },
{ $eq: ['$idapp', '$$idapp'] },
],
},
},
},
],
as: params.lk_as,
},
},
{ $project: proj },
];
return myquery;
},
getLookup: function (params, num, pass_proj) {
const query = [];
@@ -2110,6 +2141,8 @@ module.exports = {
}, 0, {
'user.idapp': 1,
'user.username': 1,
'user.name': 1,
'user.surname': 1,
'user.profile.img': 1,
'user.profile.qualifica': 1,
});
@@ -2180,6 +2213,83 @@ module.exports = {
},
},
);
} else if (params.querytype === shared_consts.QUERYTYPE_GROUP_CIRCUIT) {
const myq = this.addQueryIdMatch(params);
if (myq)
query.push(myq);
query.push({ $project: { req_groups: 1 } });
const qa1 = this.getLookup(
{
lk_tab: 'mygroups',
lk_LF: 'req_groups.groupname',
lk_FF: 'groupname',
lk_as: 'group',
}, 0, {
'group.idapp': 1,
'group.groupname': 1,
'group.photos': 1,
});
if (qa1) query = [...query, ...qa1];
query.push({ $unwind: '$group' });
query.push({
$match: {
$and: [
{ 'group.idapp': params.idapp },
],
},
});
query.push({
$replaceRoot: {
newRoot: '$group',
},
},
);
} else if (params.querytype === shared_consts.QUERYTYPE_REFUSED_GROUP_CIRCUIT) {
const myq = this.addQueryIdMatch(params);
if (myq)
query.push(myq);
query.push({ $project: { refused_groups: 1 } });
query.push({ $unwind: '$refused_groups' });
const qa1 = this.getGroupnameLookupPipeLine(
{
lk_tab: 'mygroups',
lk_LF: 'refused_groups.groupname',
lk_FF: 'groupname',
lk_as: 'group',
idapp,
}, {
'group.idapp': 1,
'group.groupname': 1,
'group.descr': 1,
'group.photos': 1,
});
if (qa1) query = [...query, ...qa1];
query.push({ $unwind: '$group' });
/*
query.push({
$match: {
$and: [
{'user.idapp': params.idapp},
],
},
});
*/
query.push({
$replaceRoot: {
newRoot: '$group',
},
},
);
} else if (params.querytype === shared_consts.QUERYTYPE_LIST_MOVEMENTS) {

View File

@@ -11,6 +11,8 @@ module.exports = {
QUERYTYPE_REFUSED_USER_CIRCUIT: 12,
QUERYTYPE_LIST_MOVEMENTS: 15,
QUERYTYPE_LIST_ALLMOVEMENTS: 16,
QUERYTYPE_GROUP_CIRCUIT: 20,
QUERYTYPE_REFUSED_GROUP_CIRCUIT: 22,
// ---------------------
FILTER_EXTRALIST_NOT_REGISTERED: 1,