Skip to content

[BE-51] Implement Reports module — GET /reports/summary for dashboard and reports page #924

Description

@yusuftomilola

Overview

This is the most urgently needed backend endpoint. The frontend dashboard (frontend/app/(dashboard)/dashboard/page.tsx) and reports page (frontend/app/(dashboard)/reports/page.tsx) both call GET /reports/summary. Without it, these pages show nothing. The dashboard is the first thing users see after login.

Context

  • Frontend API: frontend/lib/api/reports.ts getSummary() calls GET /reports/summary
  • Frontend React Query hook: frontend/lib/query/hooks/useReports.ts useReportsSummary
  • Expected response shape (from frontend types): { total, byStatus: { ACTIVE, ASSIGNED, MAINTENANCE, RETIRED }, byCategory: [{ name, count }], byDepartment: [{ name, count }], recentAssets: Asset[], totalValue: number }
  • All queries must use TypeORM aggregate functions — not multiple round-trips

Acceptance Criteria

  • Create ReportsModule, ReportsController, ReportsService
  • GET /reports/summary — single endpoint performing: total asset count, count grouped by status (all 4 statuses), count grouped by category.name (top 10), count grouped by department.name (all), sum of currentValue as totalValue, 10 most recently created assets with relations
  • Apply RBAC scoping: MANAGER only sees their department's data; ADMIN sees all
  • Apply Redis cache (CacheInterceptor) with 5-minute TTL; invalidate on any asset write operation
  • Register ReportsModule in AppModule
  • Protect with JwtAuthGuard

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions