Circuits...
Circuits Fido e Max Qta Fixed error eslint: 7.0.0 is OK
This commit is contained in:
365
query_gruppi.js
365
query_gruppi.js
@@ -1,280 +1,119 @@
|
||||
db.getCollection('myskills').aggregate(
|
||||
db.getCollection('movements').aggregate(
|
||||
[
|
||||
{
|
||||
"$match": {
|
||||
"idapp": "13"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$sort": {
|
||||
"date_created": -1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$addFields": {
|
||||
"myId1": {
|
||||
"$toObjectId": "$userId"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "users",
|
||||
"localField": "myId1",
|
||||
"foreignField": "_id",
|
||||
"as": "user"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$user",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recGood": 1,
|
||||
"sectorGood": 1,
|
||||
"idSectorGood": 1,
|
||||
"idGood": 1,
|
||||
"mygood": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"pub_to_share": 1,
|
||||
"numLevel": 1,
|
||||
"adType": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"website": 1,
|
||||
"descr": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "goods",
|
||||
"localField": "idGood",
|
||||
"foreignField": "_id",
|
||||
"as": "recGood"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$recGood",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recGood": 1,
|
||||
"sectorGood": 1,
|
||||
"idSectorGood": 1,
|
||||
"idGood": 1,
|
||||
"mygood": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"pub_to_share": 1,
|
||||
"numLevel": 1,
|
||||
"adType": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"website": 1,
|
||||
"descr": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "sectorgoods",
|
||||
"localField": "recGood.idSectorGood",
|
||||
"foreignField": "_id",
|
||||
"as": "sectorGood"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$sectorgood",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recGood": 1,
|
||||
"sectorGood": 1,
|
||||
"idSectorGood": 1,
|
||||
"idGood": 1,
|
||||
"mygood": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"pub_to_share": 1,
|
||||
"numLevel": 1,
|
||||
"adType": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"website": 1,
|
||||
"descr": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "cities",
|
||||
"localField": "idCity",
|
||||
"foreignField": "_id",
|
||||
"as": "mycities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$replaceRoot": {
|
||||
"newRoot": {
|
||||
"$mergeObjects": [
|
||||
{
|
||||
"$arrayElemAt": [
|
||||
"$mycities",
|
||||
0
|
||||
]
|
||||
},
|
||||
"$$ROOT"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"recGood": 1,
|
||||
"sectorGood": 1,
|
||||
"idSectorGood": 1,
|
||||
"idGood": 1,
|
||||
"mygood": 1,
|
||||
"idStatusSkill": 1,
|
||||
"idContribType": 1,
|
||||
"idCity": 1,
|
||||
"pub_to_share": 1,
|
||||
"numLevel": 1,
|
||||
"adType": 1,
|
||||
"photos": 1,
|
||||
"note": 1,
|
||||
"website": 1,
|
||||
"descr": 1,
|
||||
"date_created": 1,
|
||||
"date_updated": 1,
|
||||
"userId": 1,
|
||||
"username": 1,
|
||||
"name": 1,
|
||||
"surname": 1,
|
||||
"comune": 1,
|
||||
"mycities": 1,
|
||||
"profile.img": 1,
|
||||
reported: 1,
|
||||
date_report: 1,
|
||||
username_who_report: 1,
|
||||
"profile.mygroups": 1,
|
||||
"profile.qualifica": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"$match": {
|
||||
"$and": [
|
||||
"idapp": "13",
|
||||
"$or": [
|
||||
{
|
||||
"mycities.reg": "EMR"
|
||||
"accountFromId": 1
|
||||
},
|
||||
{
|
||||
"idCity": 5730
|
||||
"accountToId": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"$group": {
|
||||
"_id": null,
|
||||
"count": {
|
||||
"$sum": 1
|
||||
},
|
||||
"results": {
|
||||
"$push": "$$ROOT"
|
||||
}
|
||||
"$lookup": {
|
||||
"from": "accounts",
|
||||
"localField": "accountFromId",
|
||||
"foreignField": "_id",
|
||||
"as": "accfrom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "accounts",
|
||||
"localField": "accountToId",
|
||||
"foreignField": "_id",
|
||||
"as": "accto"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$unwind": "$accfrom"
|
||||
},
|
||||
{
|
||||
"$unwind": "$accto"
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "users",
|
||||
"let": {
|
||||
"username": "$accfrom.username",
|
||||
"idapp": "$accfrom.idapp"
|
||||
},
|
||||
"pipeline": [
|
||||
{
|
||||
"$match": {
|
||||
"$expr": {
|
||||
"$and": [
|
||||
{
|
||||
"$eq": [
|
||||
"$$username",
|
||||
"$username"
|
||||
]
|
||||
},
|
||||
{
|
||||
"$eq": [
|
||||
"$$idapp",
|
||||
"$idapp"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"as": "userfrom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$unwind": "$userfrom"
|
||||
},
|
||||
{
|
||||
"$lookup": {
|
||||
"from": "users",
|
||||
"let": {
|
||||
"username": "$accto.username",
|
||||
"idapp": "$accto.idapp"
|
||||
},
|
||||
"pipeline": [
|
||||
{
|
||||
"$match": {
|
||||
"$expr": {
|
||||
"$and": [
|
||||
{
|
||||
"$eq": [
|
||||
"$$username",
|
||||
"$username"
|
||||
]
|
||||
},
|
||||
{
|
||||
"$eq": [
|
||||
"$$idapp",
|
||||
"$idapp"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"as": "userto"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$unwind": "$userto"
|
||||
},
|
||||
{
|
||||
"$project": {
|
||||
"count": 1,
|
||||
"rows": {
|
||||
"$slice": [
|
||||
"$results",
|
||||
0,
|
||||
20
|
||||
]
|
||||
}
|
||||
"transactionDate": 1,
|
||||
"amount": 1,
|
||||
"causal": 1,
|
||||
"userfrom.username": 1,
|
||||
"userfrom.profile.img": 1
|
||||
"userto.username": 1,
|
||||
"userto.profile.img": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user