Optimize product detail analytics loading
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 43s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 43s
This commit is contained in:
@@ -5,6 +5,7 @@ const {
|
||||
getClientDetailsAnalytics,
|
||||
getDashboardAnalytics,
|
||||
getProductAnalytics,
|
||||
getProductDetailsAnalytics,
|
||||
getRfmAnalytics
|
||||
} = require('../services/analyticsService');
|
||||
|
||||
@@ -33,6 +34,21 @@ router.get('/analytics/products', verifyToken, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/analytics/products/:productId/details', verifyToken, async (req, res) => {
|
||||
try {
|
||||
const details = await getProductDetailsAnalytics(req.params.productId, getRange(req.query));
|
||||
if (!details) {
|
||||
res.status(404).json({ error: 'Product not found' });
|
||||
return;
|
||||
}
|
||||
|
||||
res.json(details);
|
||||
} catch (error) {
|
||||
console.error('Error fetching product details analytics:', error);
|
||||
res.status(500).json({ error: 'Internal Server Error' });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/analytics/clients', verifyToken, async (req, res) => {
|
||||
try {
|
||||
res.json(await getClientAnalytics(getRange(req.query)));
|
||||
|
||||
Reference in New Issue
Block a user