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 { quarter, year } = req.query;
let whereCond = {}; let whereCond = {};
if(quarter != 'All' && year != 'All')
{
// if quarter/year not passed → take latest open config // if quarter/year not passed → take latest open config
if (!quarter || !year) { // if (!quarter || !year) {
const lastConfig = await QuarterlyWindowsConfiguration.findOne({ // const lastConfig = await QuarterlyWindowsConfiguration.findOne({
order: [ // order: [
['year', 'DESC'], // ['year', 'DESC'],
['quarter', 'DESC'] // ['quarter', 'DESC']
] // ]
}); // });
if (lastConfig) { // if (lastConfig) {
quarter = lastConfig.quarter; // quarter = lastConfig.quarter;
year = lastConfig.year; // 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 (quarter) whereCond.quarter = quarter;
if (year) whereCond.year = year; if (year) whereCond.year = year;
}
const quarterlyWindows = await QuarterlyWindowsConfiguration.findOne({ where: whereCond }); const quarterlyWindows = await QuarterlyWindowsConfiguration.findOne({ where: whereCond });