fix Richieste e Rifiutati (Circuiti)
This commit is contained in:
@@ -2,18 +2,6 @@ use('test_FreePlanet');
|
||||
|
||||
let passo1 =
|
||||
[
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
"profile.mycircuits": {
|
||||
$elemMatch: {
|
||||
circuitname: {
|
||||
$eq: "Riso Rovigo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "circuits",
|
||||
@@ -49,62 +37,6 @@ let passo1 =
|
||||
|
||||
];
|
||||
|
||||
let passo1b = [
|
||||
{
|
||||
$lookup: {
|
||||
from: "accounts",
|
||||
as: "account",
|
||||
let: {
|
||||
username: "$username",
|
||||
idapp: "$idapp",
|
||||
circuitId: "$circuit._id",
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$username",
|
||||
"$username",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$circuitId",
|
||||
"$circuitId",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: "$account",
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
idapp: "13",
|
||||
},
|
||||
},
|
||||
{
|
||||
$sort: {
|
||||
desc: 1,
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
let passo1c = [
|
||||
{
|
||||
$match: {
|
||||
@@ -122,6 +54,7 @@ let passo1c = [
|
||||
let passo2 = [
|
||||
{
|
||||
$project: {
|
||||
name: 1,
|
||||
'req_users': 1,
|
||||
},
|
||||
},
|
||||
@@ -239,8 +172,9 @@ if (test) {
|
||||
// aggregation = [...aggregation, ...passo1];
|
||||
aggregation = [...aggregation, ...passo1];
|
||||
// aggregation = [...aggregation, ...passo1b];
|
||||
// aggregation = [...aggregation, ...passo1c];
|
||||
// aggregation = [...aggregation, ...passo2];
|
||||
aggregation = [...aggregation, ...passo1c];
|
||||
aggregation = [...aggregation, ...passo2];
|
||||
aggregation = [...aggregation, ...passo2b];
|
||||
}
|
||||
|
||||
db.circuits.aggregate(aggregation);
|
||||
|
||||
@@ -1565,6 +1565,37 @@ module.exports = {
|
||||
return (myapp) ? myapp.telegram_key : '';
|
||||
},
|
||||
|
||||
getLookupPipeLine(params, proj) {
|
||||
|
||||
let myquery = [
|
||||
{
|
||||
$lookup: {
|
||||
from: params.lk_tab,
|
||||
let: { username: '$' + 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 = [];
|
||||
|
||||
@@ -1950,16 +1981,24 @@ module.exports = {
|
||||
query.push(myq);
|
||||
*/
|
||||
|
||||
const myq = this.addQueryIdMatch(params);
|
||||
if (myq)
|
||||
query.push(myq);
|
||||
|
||||
query.push({ $project: { refused_users: 1 } });
|
||||
const qa1 = this.getLookup(
|
||||
query.push({ $unwind: '$refused_users' });
|
||||
const qa1 = this.getLookupPipeLine(
|
||||
{
|
||||
lk_tab: 'users',
|
||||
lk_LF: 'refused_users.username',
|
||||
lk_FF: 'username',
|
||||
lk_as: 'user',
|
||||
}, 0, {
|
||||
idapp,
|
||||
}, {
|
||||
'user.idapp': 1,
|
||||
'user.username': 1,
|
||||
'user.name': 1,
|
||||
'user.surname': 1,
|
||||
'user.profile.img': 1,
|
||||
'user.profile.qualifica': 1,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user