feat: add dashboard aggregation endpoint (Phase 2I)
GET /api/dashboard returns aggregated data: - deadline_summary: overdue, due this/next week, ok counts - case_summary: active, new this month, closed counts - upcoming_deadlines: next 7 days with case info - upcoming_appointments: next 7 days - recent_activity: last 10 case events Uses efficient CTE query for summaries. Also fixes duplicate writeJSON/writeError declarations in appointments handler.
This commit is contained in:
@@ -27,6 +27,8 @@ func New(db *sqlx.DB, authMW *auth.Middleware) http.Handler {
|
||||
// Middleware
|
||||
tenantResolver := auth.NewTenantResolver(tenantSvc)
|
||||
|
||||
dashboardSvc := services.NewDashboardService(db)
|
||||
|
||||
// Handlers
|
||||
tenantH := handlers.NewTenantHandler(tenantSvc)
|
||||
caseH := handlers.NewCaseHandler(caseSvc)
|
||||
@@ -35,6 +37,7 @@ func New(db *sqlx.DB, authMW *auth.Middleware) http.Handler {
|
||||
deadlineH := handlers.NewDeadlineHandlers(deadlineSvc, db)
|
||||
ruleH := handlers.NewDeadlineRuleHandlers(deadlineRuleSvc)
|
||||
calcH := handlers.NewCalculateHandlers(calculator, deadlineRuleSvc)
|
||||
dashboardH := handlers.NewDashboardHandler(dashboardSvc)
|
||||
|
||||
// Public routes
|
||||
mux.HandleFunc("GET /health", handleHealth(db))
|
||||
@@ -86,6 +89,9 @@ func New(db *sqlx.DB, authMW *auth.Middleware) http.Handler {
|
||||
scoped.HandleFunc("PUT /api/appointments/{id}", apptH.Update)
|
||||
scoped.HandleFunc("DELETE /api/appointments/{id}", apptH.Delete)
|
||||
|
||||
// Dashboard
|
||||
scoped.HandleFunc("GET /api/dashboard", dashboardH.Get)
|
||||
|
||||
// Placeholder routes for future phases
|
||||
scoped.HandleFunc("GET /api/documents", placeholder("documents"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user