++ aggiunta la prenotazione negli eventi. con la lista degli utenti.

This commit is contained in:
Surya Paolo
2023-04-17 00:11:36 +02:00
parent eea6e63c58
commit 0945f1af08
22 changed files with 636 additions and 157 deletions

View File

@@ -679,7 +679,9 @@ module.exports = {
return [
'idapp',
'userId',
'username',
'id_bookedevent',
'tableType',
'numpeople',
'numpeopleLunch',
'numpeopleDinner',
@@ -1455,8 +1457,9 @@ module.exports = {
} else {
return {
exit: true,
ret: res.status(404).
send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER }),
ret: false,
// ret: res.status(404).
// send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER }),
};
}
} else {
@@ -1836,18 +1839,33 @@ module.exports = {
foreignField: params.lk_FF, // field in the 'from' collection
as: params.lk_as,
},
},
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
'$' + params.lk_as, 0],
}, '$$ROOT'],
});
if (params.unwind) {
query.push({
$unwind: {
path: '$' + params.lk_as,
preserveNullAndEmptyArrays: true,
}
})
}
if (!params.noarray) {
query.push(
{
$replaceRoot: {
newRoot: {
$mergeObjects: [
{
$arrayElemAt: [
'$' + params.lk_as, 0],
}, '$$ROOT'],
},
},
},
},
});
}
query.push(
{ $project: proj },
);
}
@@ -2012,21 +2030,148 @@ module.exports = {
as: 'myseen',
},
},
];
{
$lookup: {
from: "users",
let: {
tab: numtab,
id: '$_id',
},
pipeline: [
{
$unwind: '$profile.attend',
},
{
$match: {
$expr: {
$and: [
{ $eq: ['$profile.attend.id', '$$id'] },
{ $eq: ['$profile.attend.tab', '$$tab'] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$project: {
username: 1, name: 1, surname: 1, 'profile.resid_province': 1, 'profile.img': 1,
'profile.qualifica': 1,
}
},
],
as: 'myattend',
},
}];
const numtabbacheca = this.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
if (numtab === numtabbacheca) {
const queryadd = this.getQueryMyBacheca();
query = [...query, ...queryadd];
}
proj = {
myfav: 1,
mybook: 1,
myseen: 1,
myattend: 1,
mybookings: 1,
};
return { query, proj };
},
getQueryMyBacheca: function () {
const arrquery = [{
$lookup: {
from: "bookings",
let: {
id: '$_id',
},
pipeline: [
{
$match: {
$expr: {
$and: [
{ $eq: ['$id_bookedevent', '$$id'] },
{ $eq: ['$idapp', idapp] },
],
},
},
},
{
$project: {
id_bookedevent: 1,
username: 1,
numpeople: 1,
numpeopleLunch: 1,
numpeopleDinner: 1,
infoevent: 1,
msgbooking: 1,
booked: 1,
datebooked: 1,
userId: 1,
}
},
],
as: 'mybookings',
},
},
/**
{
$lookup: {
from: "users",
localField: "myId1",
foreignField: "_id",
as: "user",
},
},
{
$lookup: {
from: "users",
let: {
myid: { $toObjectId: "$mybookings.userId" },
},
pipeline: [
{
$match: {
$expr: {
$and: [
{
$eq: [
"$_id",
"$$myid",
],
},
{
$eq: [
"$idapp",
"13",
],
},
],
},
},
},
{
$project: { _id: 1, username: 1 },
}
],
as: "myuser",
},
}**/
];
return arrquery;
},
getQueryTable: async function (idapp, params, user) {
const { Search }= require('../models/search');
const { Search } = require('../models/search');
if (typeof params.startRow !== 'number') {
throw new Error('startRow must be number');
@@ -2610,7 +2755,7 @@ module.exports = {
// Save the search:
if (user._id) {
const mysearch = new Search({idapp, userId: user._id, text: params.filter});
const mysearch = new Search({ idapp, userId: user._id, text: params.filter });
await mysearch.save();
}
}
@@ -3875,7 +4020,7 @@ module.exports = {
},
updateQueryStringParameter(uri, key, value) {
if (uri === '')
if (uri === '' || !uri)
return '';
var re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
var separator = uri.indexOf('?') !== -1 ? '&' : '?';