From a397423aafc6de67c12a3760bdae240aef71210e Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 11 Nov 2025 18:24:14 +0530 Subject: [PATCH] admin dashboard All data fetch --- app/controllers/dashboard.controller.js | 37 +++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/app/controllers/dashboard.controller.js b/app/controllers/dashboard.controller.js index 4e2c87c..6cc0aea 100644 --- a/app/controllers/dashboard.controller.js +++ b/app/controllers/dashboard.controller.js @@ -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 });