From b495cf88239c96de75f68bb5779464c68b00f2b8 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 11 Nov 2025 18:06:43 +0530 Subject: [PATCH 1/2] admin dashboard All data fetch --- app/controllers/dashboard.controller.js | 40 +++++++++++++++---------- app/routes/routes.js | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/controllers/dashboard.controller.js b/app/controllers/dashboard.controller.js index 6bb3171..4e2c87c 100644 --- a/app/controllers/dashboard.controller.js +++ b/app/controllers/dashboard.controller.js @@ -188,24 +188,32 @@ exports.adminDashboard = async (req, res) => { try { let { quarter, year } = req.query; - // if quarter/year not passed → take latest open config - if (!quarter || !year) { - const lastConfig = await QuarterlyWindowsConfiguration.findOne({ - order: [ - ['year', 'DESC'], - ['quarter', 'DESC'] - ] - }); + 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 (lastConfig) { + quarter = lastConfig.quarter; + year = lastConfig.year; + } + } + + whereCond = {}; + if (quarter) whereCond.quarter = quarter; + if (year) whereCond.year = year; - if (lastConfig) { - quarter = lastConfig.quarter; - year = lastConfig.year; - } } - const whereCond = {}; - if (quarter) whereCond.quarter = quarter; - if (year) whereCond.year = year; + const quarterlyWindows = await QuarterlyWindowsConfiguration.findOne({ where: whereCond }); @@ -256,7 +264,7 @@ exports.adminDashboard = async (req, res) => { ], }, order: [["created_at", "DESC"]], - limit: 10, + // limit: 10, }); return res.status(200).json({ diff --git a/app/routes/routes.js b/app/routes/routes.js index 4a3d7fa..37b8853 100644 --- a/app/routes/routes.js +++ b/app/routes/routes.js @@ -2381,7 +2381,7 @@ router.get("/establishment_dashboard",[verifySignature, verifyToken],dashboardCo * name: year * required: false * schema: - * type: integer + * type: string * responses: * 200: * description: Dashboard data fetched successfully From a397423aafc6de67c12a3760bdae240aef71210e Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Tue, 11 Nov 2025 18:24:14 +0530 Subject: [PATCH 2/2] 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 });