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 GetStats(CancellationToken ct) { var stats = await _statsService.GetStatsAsync(ct); return Ok(new { totalSites = stats.TotalSites, totalCameras = stats.TotalCameras, totalAgents = stats.TotalAgents, onlineAgents = stats.OnlineAgents, activeSites = stats.ActiveSites, timestamp = DateTime.UtcNow }); } }