++ DebugOn status (to see what happened)

fix visu activities
This commit is contained in:
Surya Paolo
2022-12-14 22:07:17 +01:00
parent 71e49c31c3
commit cce311cc2c
3 changed files with 249 additions and 1 deletions

View File

@@ -0,0 +1,246 @@
use('test_FreePlanet');
let passo1 =
[
{
$match: {
idapp: "13",
"profile.mycircuits": {
$elemMatch: {
circuitname: {
$eq: "Riso Rovigo",
},
},
},
},
},
{
$lookup: {
from: "circuits",
as: "circuit",
let: {
circuitname: "Riso Rovigo",
idapp: "$idapp",
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$name",
"$$circuitname",
],
},
{
$eq: [
"$idapp",
"$$idapp",
],
},
],
},
},
},
],
},
},
];
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: {
$expr: {
$eq: [
"$_id",
"633ed3454b03da33f944da14",
],
},
},
},
];
let passo2 = [
{
$project: {
'req_users': 1,
},
},
];
let passo2b = [
{
$lookup: {
from: "users",
localField: "req_users.username",
foreignField: "username",
as: "user",
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
"$user",
0,
],
},
"$$ROOT",
],
},
},
},
{
$project: {
"user.idapp": 1,
"user.username": 1,
"user.profile.img": 1,
"user.profile.qualifica": 1,
},
},
{
$unwind: "$user",
},
{
$match: {
$and: [
{
"user.idapp": "13",
},
],
},
},
{
$replaceRoot: {
newRoot: "$user",
},
},
{
$match: {
$and: [
{
$or: [
{
visibility: {
$nin: [
2,
],
},
},
{
createdBy: {
$eq: "paoloar77",
},
},
],
},
],
},
},
{
$group: {
_id: null,
count: {
$sum: 1,
},
results: {
$push: "$$ROOT",
},
},
},
{
$project: {
count: 1,
rows: {
$slice: [
"$results",
0,
10,
],
},
},
},
];
let passo3 = [
];
let aggregation = [];
let test = false;
if (test) {
aggregation = [...aggregation, ...passo4];
} else {
// aggregation = [...aggregation, ...passo1];
aggregation = [...aggregation, ...passo1];
// aggregation = [...aggregation, ...passo1b];
// aggregation = [...aggregation, ...passo1c];
// aggregation = [...aggregation, ...passo2];
}
db.circuits.aggregate(aggregation);

View File

@@ -217,7 +217,8 @@ CircuitSchema.statics.getFieldsForSearch = function() {
{field: 'nome_circuito', type: tools.FieldType.string},
{field: 'sotto_nome', type: tools.FieldType.string},
{field: 'nome_valuta', type: tools.FieldType.string},
{field: 'descr', type: tools.FieldType.string}];
{field: 'descr', type: tools.FieldType.string},
];
};
CircuitSchema.statics.executeQueryTable = function(idapp, params, user) {

View File

@@ -120,6 +120,7 @@ const SiteSchema = new Schema({
enableTodos: { type: Boolean },
enableRegByBot: { type: Boolean },
enableRegMultiChoice: { type: Boolean },
enableDebugOn: { type: Boolean },
enabledRegNeedTelegram: { type: Boolean },
showViewGroups: { type: Boolean },
showViewCircuits: { type: Boolean },