admin dashboard All data fetch
This commit is contained in:
parent
01d5c7a1c0
commit
b495cf8823
@ -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({
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user