Conti Comunitari e Collettivi

This commit is contained in:
Surya Paolo
2023-02-01 16:36:10 +01:00
parent 9a0f0a0cc6
commit aa9d27c8fd
10 changed files with 183 additions and 58 deletions

View File

@@ -128,7 +128,7 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
if (!circuitId) {
return [];
}
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false);
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, '');
if (myaccount) {
@@ -196,6 +196,29 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
},
},
{$unwind: '$groupfrom'},
{
$lookup: {
from: 'circuits',
let: {contocom: '$accfrom.contocom', idapp: '$accfrom.idapp'},
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{$eq: ['$$contocom', '$path']},
{$eq: ['$$idapp', '$idapp']},
],
},
},
},
],
as: 'contocomfrom',
},
},
{$unwind: '$contocomfrom'},
{
$lookup: {
from: 'accounts',
@@ -273,6 +296,29 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
},
},
{$unwind: '$groupto'},
{
$lookup: {
from: 'circuits',
let: {contocom: '$accto.contocom', idapp: '$accto.idapp'},
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{$eq: ['$$contocom', '$path']},
{$eq: ['$$idapp', '$idapp']},
],
},
},
},
],
as: 'contocomto',
},
},
{$unwind: '$contocomto'},
{
$project:
{
@@ -288,6 +334,8 @@ MovementSchema.statics.getQueryMovsByCircuitId = async function(idapp, username,
'userto.profile.img': 1,
'groupfrom.groupname': 1,
'groupto.groupname': 1,
'contocomfrom.path': 1,
'contocomto.path': 1,
},
},
@@ -380,6 +428,34 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'circuits',
let: {contocom: '$accfrom.contocom', idapp: '$accfrom.idapp'},
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{$eq: ['$$contocom', '$path']},
{$eq: ['$$idapp', '$idapp']},
],
},
},
},
],
as: 'contocomfrom',
},
},
{
$unwind: {
path: '$contocomfrom',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'accounts',
@@ -481,6 +557,34 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'circuits',
let: {contocom: '$accto.contocom', idapp: '$accto.idapp'},
pipeline: [
{
$match:
{
$expr:
{
$and:
[
{$eq: ['$$contocom', '$path']},
{$eq: ['$$idapp', '$idapp']},
],
},
},
},
],
as: 'contocomto',
},
},
{
$unwind: {
path: '$contocomto',
preserveNullAndEmptyArrays: true,
},
},
{
$project:
{
@@ -496,6 +600,8 @@ MovementSchema.statics.getQueryAllUsersMovsByCircuitId = async function(idapp, c
'userto.profile.img': 1,
'groupfrom.groupname': 1,
'groupto.groupname': 1,
'contocomfrom.path': 1,
'contocomto.path': 1,
},
},