feat: add fleet-wide fuel and maintenance stats endpoints

Backend:
FuelService + FuelController:
- Added getFleetFuelStats() aggregating all vehicles
- Route: GET /api/fuel/stats (before :vehicleId route)
- Returns: totalCost, totalLiters, totalPurchases, averagePricePerLiter

MaintenanceService + MaintenanceController:
- Added getFleetMaintenanceStats() aggregating all vehicles
- Route: GET /api/maintenance/stats (before :vehicleId route)
- Returns: totalCost, numberOfMaintenanceItems, averageCostPerMaintenance, costByType

Both endpoints aggregate over past 12 months (customizable via query param).

Enables dashboard to show fleet-wide operating costs.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
natib21
2026-06-30 14:32:12 +00:00
parent 17a6d846a4
commit 558f7f38cd
4 changed files with 54 additions and 0 deletions

View File

@@ -38,6 +38,12 @@ export class MaintenanceController {
return this.maintenanceService.getMaintenanceHistory(vehicleId);
}
@Get('stats')
@ApiOperation({ summary: 'Get fleet-wide maintenance statistics' })
async getFleetStats() {
return this.maintenanceService.getFleetMaintenanceStats();
}
@Get('stats/:vehicleId')
@ApiOperation({ summary: 'Get maintenance statistics' })
async getStats(@Param('vehicleId') vehicleId: string) {