Project e Todos sistemati...
aggiunti Gruppi
This commit is contained in:
@@ -55,13 +55,15 @@ var TodoSchema = new mongoose.Schema({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
id_prev: mongoose.Schema.Types.ObjectId,
|
||||
progress: {
|
||||
type: Number,
|
||||
},
|
||||
phase: {
|
||||
type: Number,
|
||||
},
|
||||
assignedToUsers: [
|
||||
{ type: String }
|
||||
],
|
||||
assigned_to_userId: {
|
||||
type: String,
|
||||
},
|
||||
@@ -81,6 +83,10 @@ var TodoSchema = new mongoose.Schema({
|
||||
modified: {
|
||||
type: Boolean,
|
||||
},
|
||||
deleted: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
TodoSchema.methods.toJSON = function () {
|
||||
@@ -115,10 +121,24 @@ TodoSchema.statics.findByUserIdAndIdParent = function (userId, category, phase =
|
||||
// User.find({ admin: true }).where('created_at').gt(monthAgo).exec(function(err, users) {
|
||||
// if (err) throw err;
|
||||
|
||||
function getQueryFilterTodo(userId) {
|
||||
let myobj = [
|
||||
{ userId: userId },
|
||||
{
|
||||
$or:
|
||||
[{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
|
||||
}
|
||||
]
|
||||
;
|
||||
return myobj;
|
||||
}
|
||||
|
||||
/*
|
||||
function getQueryFilterTodo(userId) {
|
||||
myobj = [{ privacyread: server_constants.Privacy.all }, { userId: userId }];
|
||||
return myobj;
|
||||
}
|
||||
*/
|
||||
|
||||
function getQueryTodo(filterMatchBefore = {}, userId) {
|
||||
|
||||
@@ -150,7 +170,14 @@ function getQueryTodo(filterMatchBefore = {}, userId) {
|
||||
TodoSchema.statics.findAllByUserIdAndCat = function (userId) {
|
||||
var Todo = this;
|
||||
|
||||
const query = getQueryTodo({}, userId);
|
||||
const query = getQueryTodo({
|
||||
$or: [{ deleted: { $exists: false } }, {
|
||||
deleted: {
|
||||
$exists: true,
|
||||
$eq: false
|
||||
}
|
||||
}]
|
||||
}, userId);
|
||||
|
||||
return Todo.aggregate(query)
|
||||
.then(ris => {
|
||||
@@ -222,8 +249,8 @@ TodoSchema.statics.getAllTodo = async function (userId) {
|
||||
if (!!arralltodo) {
|
||||
const arrfiltrato = arralltodo.filter(item => item.category.toString() === mycat.toString());
|
||||
if (arrfiltrato.length > 0) {
|
||||
const arrmap = tools.mapSort(arrfiltrato);
|
||||
arrtodos.push(arrmap);
|
||||
// const arrmap = tools.mapSort(arrfiltrato);
|
||||
arrtodos.push(arrfiltrato);
|
||||
// console.log('AGGIUNGI RECORDS TODO! cat: ', mycat, 'da aggiungere:', arrfiltrato.length, 'attuali', arrtodos.length);
|
||||
// console.log(arrtodos)
|
||||
} else {
|
||||
@@ -335,7 +362,7 @@ class CalcTodo {
|
||||
if (this.mydata.numitem > 0) {
|
||||
this.mydata.progressCalc = Math.round(this.mydata.progressCalc / this.mydata.numitem);
|
||||
}
|
||||
console.log('this.mydata.progressCalc', this.mydata.progressCalc)
|
||||
// console.log('this.mydata.progressCalc', this.mydata.progressCalc)
|
||||
}
|
||||
|
||||
getData() {
|
||||
|
||||
Reference in New Issue
Block a user