End "project and Todos": what could modify or readonly.
This commit is contained in:
@@ -146,7 +146,7 @@ ProjectSchema.statics.findProjectByUserId = function (userId, idproj) {
|
||||
} else {
|
||||
return Project.findOne({
|
||||
'userId': userId,
|
||||
'_id': ObjectId(idproj),
|
||||
'_id': idproj,
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -156,6 +156,7 @@ ProjectSchema.statics.findAllProjByUserId = async function (userId) {
|
||||
var Project = this;
|
||||
|
||||
return Project.aggregate([
|
||||
{ $match: { $or: [{ privacyread: server_constants.Privacy.all }, { userId: userId }] } },
|
||||
{
|
||||
$graphLookup: {
|
||||
from: "projects",
|
||||
|
||||
@@ -140,26 +140,17 @@ function getQueryTodo(filterMatchBefore = {}, userId) {
|
||||
return query;
|
||||
}
|
||||
|
||||
TodoSchema.statics.findAllByUserIdAndCat = function (userId, category = '') {
|
||||
TodoSchema.statics.findAllByUserIdAndCat = function (userId) {
|
||||
var Todo = this;
|
||||
|
||||
if (category === '') {
|
||||
const query = getQueryTodo({}, userId);
|
||||
|
||||
const query = getQueryTodo({}, userId);
|
||||
|
||||
return Todo.aggregate(query)
|
||||
.then(ris => {
|
||||
// console.log('ris TODO:', ris);
|
||||
//return tools.mapSort(ris)
|
||||
return ris
|
||||
});
|
||||
|
||||
} else {
|
||||
return Todo.find({
|
||||
'userId': userId,
|
||||
'category': category,
|
||||
return Todo.aggregate(query)
|
||||
.then(ris => {
|
||||
// console.log('ris TODO:', ris);
|
||||
//return tools.mapSort(ris)
|
||||
return ris
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
TodoSchema.statics.getArrIdParentInTable = function (userId) {
|
||||
@@ -216,7 +207,7 @@ TodoSchema.statics.getAllTodo = async function (userId) {
|
||||
|
||||
obj.arrcategories = await Todo.getArrIdParentInTable(userId);
|
||||
|
||||
console.log('obj.arrcategories', obj.arrcategories);
|
||||
// console.log('obj.arrcategories', obj.arrcategories);
|
||||
|
||||
let arrtodos = [];
|
||||
if (obj.arrcategories.length > 0) {
|
||||
@@ -226,7 +217,10 @@ TodoSchema.statics.getAllTodo = async function (userId) {
|
||||
if (arrfiltrato.length > 0) {
|
||||
const arrmap = tools.mapSort(arrfiltrato);
|
||||
arrtodos.push(arrmap);
|
||||
console.log('AGGIUNGI RECORDS TODO! cat: ', mycat, 'da aggiungere:', arrfiltrato.length, 'attuali', arrtodos.length);
|
||||
// console.log('AGGIUNGI RECORDS TODO! cat: ', mycat, 'da aggiungere:', arrfiltrato.length, 'attuali', arrtodos.length);
|
||||
// console.log(arrtodos)
|
||||
} else {
|
||||
arrtodos.push([]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,12 +228,33 @@ TodoSchema.statics.getAllTodo = async function (userId) {
|
||||
|
||||
obj.arrtodos = arrtodos;
|
||||
|
||||
console.log('obj.arrtodos', obj.arrtodos);
|
||||
// console.log('obj.arrtodos:');
|
||||
// logtodo(obj.arrtodos);
|
||||
|
||||
return obj;
|
||||
|
||||
};
|
||||
|
||||
function getelem(item) {
|
||||
return item.descr + ' ' + item.category;
|
||||
}
|
||||
|
||||
function logtodo(myarr) {
|
||||
console.log(getarrlog(myarr));
|
||||
}
|
||||
|
||||
function getarrlog(myarr) {
|
||||
let mystr = "";
|
||||
for (const indcat in myarr){
|
||||
mystr += indcat + ': \n';
|
||||
for (const indelem in myarr[indcat]) {
|
||||
mystr += ' [' + indelem + '] ' + getelem(myarr[indcat][indelem]) + '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return mystr
|
||||
}
|
||||
|
||||
class CalcTodo {
|
||||
constructor(phase) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user