2026-04-16 19:25:42 -04:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2026-09-16 17:28:21 -03:00
|
|
|
using SeaHaven.Services.DTOs;
|
2026-07-24 17:35:34 -03:00
|
|
|
using SeaHaven.Services.Interfaces;
|
2026-04-16 19:25:42 -04:00
|
|
|
|
|
|
|
|
namespace Api.SeaHavenIndustries.Controllers
|
|
|
|
|
{
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiController]
|
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
|
public class DashboardController : Controller
|
|
|
|
|
{
|
2026-07-24 17:35:34 -03:00
|
|
|
private readonly IDashboardService _dashboardService;
|
2026-04-16 19:25:42 -04:00
|
|
|
|
2026-07-24 17:35:34 -03:00
|
|
|
public DashboardController(IDashboardService dashboardService)
|
2026-04-16 19:25:42 -04:00
|
|
|
{
|
2026-07-24 17:35:34 -03:00
|
|
|
_dashboardService = dashboardService;
|
2026-04-16 19:25:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet("Stats")]
|
2026-09-16 17:28:21 -03:00
|
|
|
public async Task<IActionResult> GetStats(
|
|
|
|
|
[FromQuery] DashboardStatsQueryDTO query,
|
|
|
|
|
CancellationToken cancellationToken)
|
2026-04-16 19:25:42 -04:00
|
|
|
{
|
2026-09-16 17:28:21 -03:00
|
|
|
var stats = await _dashboardService.GetStatsAsync(User, query, cancellationToken);
|
2026-04-16 19:25:42 -04:00
|
|
|
|
|
|
|
|
return Ok(new
|
|
|
|
|
{
|
2026-07-24 17:35:34 -03:00
|
|
|
total = stats.Total,
|
|
|
|
|
open = stats.Open,
|
|
|
|
|
notDispatched = stats.NotDispatched,
|
2026-09-16 17:28:21 -03:00
|
|
|
completed = stats.Completed,
|
|
|
|
|
breakdown = stats.Breakdown,
|
|
|
|
|
dueCount = stats.DueCount,
|
|
|
|
|
completedDueCount = stats.CompletedDueCount,
|
|
|
|
|
completionRate = stats.CompletionRate,
|
|
|
|
|
averageResolutionDays = stats.AverageResolutionDays
|
2026-04-16 19:25:42 -04:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|