Add RFM segmentation analytics
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m12s

This commit is contained in:
Cauê Faleiros
2026-06-12 11:22:57 -03:00
parent 25ab6cd448
commit fe8d0ff105
10 changed files with 1231 additions and 14 deletions

View File

@@ -3,7 +3,8 @@ const { verifyToken } = require('../auth');
const {
getClientAnalytics,
getDashboardAnalytics,
getProductAnalytics
getProductAnalytics,
getRfmAnalytics
} = require('../services/analyticsService');
const router = express.Router();
@@ -40,4 +41,13 @@ router.get('/analytics/clients', verifyToken, async (req, res) => {
}
});
router.get('/analytics/rfm', verifyToken, async (req, res) => {
try {
res.json(await getRfmAnalytics(getRange(req.query)));
} catch (error) {
console.error('Error fetching RFM analytics:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});
module.exports = router;