admin dashboard All data fetch

This commit is contained in:
Gowtham M 2025-11-11 18:24:14 +05:30
parent 2dd2634242
commit a397423aaf

View File

@ -189,31 +189,32 @@ exports.adminDashboard = async (req, res) => {
let { quarter, year } = req.query;
let whereCond = {};
if(quarter != 'All' && year != 'All')
{
// if quarter/year not passed → take latest open config
if (!quarter || !year) {
const lastConfig = await QuarterlyWindowsConfiguration.findOne({
order: [
['year', 'DESC'],
['quarter', 'DESC']
]
});
// if (!quarter || !year) {
// const lastConfig = await QuarterlyWindowsConfiguration.findOne({
// order: [
// ['year', 'DESC'],
// ['quarter', 'DESC']
// ]
// });
if (lastConfig) {
quarter = lastConfig.quarter;
year = lastConfig.year;
}
}
// if (lastConfig) {
// quarter = lastConfig.quarter;
// year = lastConfig.year;
// }
// }
whereCond = {};
// Convert 'All' → undefined (no filter)
if (quarter === 'All') quarter = null;
if (year === 'All') year = null;
// Build where condition dynamically
if (quarter) whereCond.quarter = quarter;
if (year) whereCond.year = year;
}
const quarterlyWindows = await QuarterlyWindowsConfiguration.findOne({ where: whereCond });