Skip to content

Commit

Permalink
attendance controller changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharjeel007305 committed May 16, 2022
1 parent 280cffc commit 7035020
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions backend/controllers/attendance_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,29 @@ module.exports.report = (req, res) => {
$cond: [{ $eq: ['$WorkingHours', true] }, 1, 0]
}
},
'TotalHolidays': {

}
}
]

const ShowLeaveagg = [
{
'$match': {
'Date.Month': req.body.Month,
'Date.Day': req.body.Day,
'Date.Year': req.body.Year
}
},
{
'$group': {
'_id': '$UserID',
'Details': {
'$push': '$$ROOT'
},

'ManualAttendance': {
'$sum': {
$cond: [{ $eq: ['$TransactionType', "Holiday"] }, 1, 0]
$cond: [{ $eq: ['$WorkingHours', true] }, 1, 0]
}
},
'Leave': {
Expand All @@ -174,13 +194,18 @@ module.exports.report = (req, res) => {
]
}
},

}

}
]
]
if (req.body.userIds && req.body.userIds.length) {
aggr[0].$match['UserName'] = { $in: req.body.userIds }
}
attendance_repo.aggregate(aggr)
attendance_repo.aggregate(aggr);
attendance_repo.aggregate(ShowLeaveagg);
let attendance = [];
attendance.push(aggr.ShowLeaveagg)
.then(attendance => {
res.send({ Status: true, data: attendance })
})
Expand Down

0 comments on commit 7035020

Please sign in to comment.