feat: Add GET /api/v1/analytics/advanced/dashboard/:childId endpoint
Some checks failed
ParentFlow CI/CD Pipeline / Backend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Frontend Tests (push) Has been cancelled
ParentFlow CI/CD Pipeline / Security Scanning (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-app/maternal-app-backend dockerfile:Dockerfile.production name:backend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Build Docker Images (map[context:maternal-web dockerfile:Dockerfile.production name:frontend]) (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Development (push) Has been cancelled
ParentFlow CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Lint and Test (push) Has been cancelled
CI/CD Pipeline / E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Application (push) Has been cancelled

- Implements comprehensive analytics dashboard aggregating multiple data sources
- Fetches circadian rhythm, anomalies, correlations, growth analysis in parallel
- Includes sleep and feeding trends and clusters
- Provides complete AdvancedAnalyticsDashboard response expected by frontend
- Resolves 404 error on frontend analytics dashboard

Endpoint analysis: 98.8% coverage (81/82 endpoints now implemented)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andrei
2025-10-10 12:22:11 +00:00
parent 0d6b901995
commit 51057a3d26

View File

@@ -392,6 +392,62 @@ export class AnalyticsController {
}
}
/**
* Advanced Analytics Dashboard - Aggregates all advanced analytics
* GET /api/v1/analytics/advanced/dashboard/:childId
*/
@Get('advanced/dashboard/:childId')
async getAdvancedDashboard(
@CurrentUser() user: any,
@Param('childId') childId: string,
) {
try {
// Fetch all analytics data in parallel for better performance
const [
circadianRhythm,
anomalies,
correlations,
growthAnalysis,
sleepTrends,
feedingTrends,
sleepClusters,
feedingClusters,
] = await Promise.all([
this.advancedPatternService.analyzeCircadianRhythm(childId, 14),
this.advancedPatternService.detectAnomalies(childId, 30),
this.advancedPatternService.analyzeCorrelations(childId, 14),
this.growthPercentileService.analyzeGrowth(childId),
this.advancedPatternService.analyzeTrends(childId, ActivityType.SLEEP),
this.advancedPatternService.analyzeTrends(childId, ActivityType.FEEDING),
this.advancedPatternService.clusterActivities(childId, ActivityType.SLEEP, 30),
this.advancedPatternService.clusterActivities(childId, ActivityType.FEEDING, 30),
]);
// Combine all analytics into a comprehensive dashboard
const dashboard = {
circadianRhythm,
anomalies,
correlations,
growthAnalysis,
trends: {
sleep: sleepTrends,
feeding: feedingTrends,
},
clusters: {
sleep: sleepClusters,
feeding: feedingClusters,
},
};
return {
success: true,
data: dashboard,
};
} catch (error) {
throw new BadRequestException(error.message);
}
}
/**
* Comprehensive Analytics Dashboard Endpoint
*/