admin dashboard All data fetch
This commit is contained in:
parent
01d5c7a1c0
commit
b495cf8823
@ -188,24 +188,32 @@ exports.adminDashboard = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
let { quarter, year } = req.query;
|
let { quarter, year } = req.query;
|
||||||
|
|
||||||
// if quarter/year not passed → take latest open config
|
let whereCond = {};
|
||||||
if (!quarter || !year) {
|
if(quarter != 'All' && year != 'All')
|
||||||
const lastConfig = await QuarterlyWindowsConfiguration.findOne({
|
{
|
||||||
order: [
|
|
||||||
['year', 'DESC'],
|
// if quarter/year not passed → take latest open config
|
||||||
['quarter', 'DESC']
|
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 });
|
const quarterlyWindows = await QuarterlyWindowsConfiguration.findOne({ where: whereCond });
|
||||||
|
|
||||||
@ -256,7 +264,7 @@ exports.adminDashboard = async (req, res) => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
order: [["created_at", "DESC"]],
|
order: [["created_at", "DESC"]],
|
||||||
limit: 10,
|
// limit: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
|
|||||||
@ -2381,7 +2381,7 @@ router.get("/establishment_dashboard",[verifySignature, verifyToken],dashboardCo
|
|||||||
* name: year
|
* name: year
|
||||||
* required: false
|
* required: false
|
||||||
* schema:
|
* schema:
|
||||||
* type: integer
|
* type: string
|
||||||
* responses:
|
* responses:
|
||||||
* 200:
|
* 200:
|
||||||
* description: Dashboard data fetched successfully
|
* description: Dashboard data fetched successfully
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user