Aggiornamento Ore

This commit is contained in:
Paolo Arena
2021-03-17 02:24:11 +01:00
parent 4800186161
commit 678d8ecd6b
14 changed files with 209 additions and 69 deletions

View File

@@ -116,6 +116,10 @@ module.exports.getHoursByIdCat = async function (idapp, userId, idCat, date_star
};
module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
const dateini = date;
const datefin = tools.AddDate(date, 1);
const myfind = [
{
$match: {
@@ -124,16 +128,15 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
hours: { $gt: 0 },
date:
{
$gte: new Date(tools.getstrDateYYYY_MM_DD(date)),
$lte: new Date(tools.getstrDateYYYY_MM_DD(tools.AddDate(date, 1)))
// $lte: new Date('2023-01-01')
$gte: dateini,
$lt: datefin,
}
},
},
{
$group:
{
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date" } },
_id: { $dateToString: { format: "%Y-%m-%d", date: "$date", timezone: 'Europe/Rome' } },
totalAmount: {
$sum: "$hours"
@@ -151,6 +154,7 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
try {
const ris = await Hours.aggregate(myfind);
if (ris.length > 0) {
// console.log('[',dateini, '-', datefin, '] TOT', ris[0].totalAmount)
return ris[0].totalAmount;
} else {
return 0;
@@ -164,7 +168,6 @@ module.exports.getTotalHoursByDate = async function (idapp, userId, date) {
module.exports.getHoursByDate = async function (idapp, userId, date) {
const mystr = tools.getstrDateYYYY_MM_DD(date);
// console.log(mystr);
const myfind =
{
@@ -172,8 +175,8 @@ module.exports.getHoursByDate = async function (idapp, userId, date) {
userId,
hours: { $gt: 0 },
date: {
$gte: new Date(tools.getstrDateYYYY_MM_DD(date)),
$lte: new Date(tools.getstrDateYYYY_MM_DD(tools.AddDate(date, 1)))
$gte: date,
$lt: tools.AddDate(date, 1)
}
};

View File

@@ -134,6 +134,9 @@ var ProjectSchema = new mongoose.Schema({
tipovisu: {
type: Number,
},
view: {
type: String,
},
deleted: {
type: Boolean,
default: false,

View File

@@ -702,6 +702,48 @@ UserSchema.statics.isUserQualified7 = async function (idapp, username) {
return !!myrec;
};
UserSchema.statics.isUserResidente = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
};
const myrec = await User.findOne(myquery);
if (!!myrec) {
return myrec.profile.socioresidente;
} else {
return false;
}
};
UserSchema.statics.isUserVisuProjects = async function (idapp, username) {
const User = this;
if (username === undefined)
return false;
const myquery = {
'idapp': idapp,
'username': username,
};
const myrec = await User.findOne(myquery);
if (!!myrec) {
return myrec.profile.socioresidente;
} else {
return false;
}
};
UserSchema.statics.isUserAlreadyQualified = async function (idapp, username) {
const User = this;
@@ -2015,7 +2057,7 @@ UserSchema.statics.getUsersRegDaily = function (idapp, nrec) {
}
},
{
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
},
{
$sort: { _id: 1 }
@@ -2034,7 +2076,7 @@ UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
}
},
{
$group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg" } }, count: { $sum: 1 } }
$group: { _id: { $dateToString: { format: "%Y-%U", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
},
{
$sort: { _id: 1 }
@@ -2055,7 +2097,7 @@ UserSchema.statics.getnumRegNDays = function (idapp, nrec) {
}
},
{
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg" } }, count: { $sum: 1 } }
$group: { _id: { $dateToString: { format: "%Y-%m-%d", date: "$date_reg", timezone: 'Europe/Rome' } }, count: { $sum: 1 } }
},
{
$sort: { _id: 1 }