feat: implement analytics endpoints (task 28)
- Created analytics service with summary, trends, comparison, and aggregated data methods - Implemented 5 analytics endpoints: summary, trends, comparison, aggregated, and CSV export - Added time series data with day/week/month interval support - Implemented period-over-period comparison metrics with percentage changes - Added CSV export functionality using json2csv - Updated frontend analytics service to unwrap API responses - Fixed chart components to work with new data structure (reportCount, eventCount, litterCollected) - Updated TypeScript types to match backend API structure - All endpoints tested and verified working Requirements satisfied: 5.1, 5.2, 5.3, 5.4, 5.5
This commit is contained in:
13
server/src/routes/analyticsRoutes.ts
Normal file
13
server/src/routes/analyticsRoutes.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Router } from 'express';
|
||||
import { analyticsController } from '../controllers/analyticsController';
|
||||
|
||||
const router = Router();
|
||||
|
||||
// Analytics endpoints
|
||||
router.get('/summary', analyticsController.getSummary.bind(analyticsController));
|
||||
router.get('/trends', analyticsController.getTrends.bind(analyticsController));
|
||||
router.get('/comparison', analyticsController.getComparison.bind(analyticsController));
|
||||
router.get('/export', analyticsController.exportCSV.bind(analyticsController));
|
||||
router.get('/aggregated', analyticsController.getAggregatedData.bind(analyticsController));
|
||||
|
||||
export default router;
|
||||
Reference in New Issue
Block a user