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.
25 lines
766 B
C#
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 });
|
|
}
|
|
}
|