Skip to content

Commit

Permalink
Merge pull request #8 from Hossain2024/backend_methods
Browse files Browse the repository at this point in the history
Backend methods
  • Loading branch information
Hossain2024 authored Mar 6, 2025
2 parents 99b438b + 404b7ca commit a9b86a8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions EmployeeManagementBackend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,29 @@ app.get('/assignTraining', (req, res)=> {
})
})


/**
*
*/
app.get('/leave-requests', (req, res) => {
const query = `
SELECT
e.EmployeeID,
e.FirstName,
e.LastName,
COUNT(lr.LeaveRequestID) AS TotalNumberOfRequests
FROM LeaveRequest lr
JOIN Employee e ON lr.EmployeeID = e.EmployeeID
GROUP BY e.EmployeeID, e.FirstName, e.LastName
ORDER BY TotalNumberOfRequests DESC;
`;

db.query(query, (err, results) => {
if (err) {
res.status(500).json({ error: 'Failed to fetch total leave requests per employee' });
} else {
res.json(results);
}
});
});

0 comments on commit a9b86a8

Please sign in to comment.