Files
Heimdall/src/Heimdall.Api/Controllers/StatsController.cs
T
Arnaud Dartois 21642bc4d6 fix(api): align IStatsService with ServiceResult pattern and fix activeSites bug
IStatsService was the only service returning raw Task<T> instead of
ServiceResult<T>. Also fixed 'activeSites = totalSites' copy-paste
bug — now counts sites where Enabled == true.
2026-07-17 19:28:02 +00:00

25 lines
766 B
C#

using Heimdall.Application.DTOs;
using Heimdall.Application.Services;
using Heimdall.Infrastructure.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Heimdall.Api.Controllers;
[ApiController]
[Route("api/stats")]
public class StatsController : ControllerBase
{
private readonly IStatsService _statsService;
public StatsController(IStatsService statsService) => _statsService = statsService;
[Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.SiteRead)]
[HttpGet]
public async Task<IActionResult> GetStats(CancellationToken ct)
{
var result = await _statsService.GetStatsAsync(ct);
return Ok(new { data = result.Data, timestamp = DateTime.UtcNow });
}
}