update top level client count stats to support filtering per game

This commit is contained in:
RaidMax
2023-04-19 19:55:33 -05:00
parent c53e0de7d0
commit 92992dfb13
8 changed files with 126 additions and 87 deletions

View File

@ -2,6 +2,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Data.Models;
using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
@ -21,13 +22,13 @@ public class Info : BaseController
}
[HttpGet]
public async Task<IActionResult> Get(int period = 24, CancellationToken token = default)
public async Task<IActionResult> Get(int period = 24, Reference.Game? game = null, CancellationToken token = default)
{
// todo: this is hardcoded currently because the cache doesn't take into consideration the duration, so
// we could impact the webfront usage too
var duration = TimeSpan.FromHours(24);
var (totalClients, totalRecentClients) =
await _serverDataViewer.ClientCountsAsync(duration, token);
await _serverDataViewer.ClientCountsAsync(duration, game, token);
var (maxConcurrent, maxConcurrentTime) = await _serverDataViewer.MaxConcurrentClientsAsync(overPeriod: duration, token: token);
var response = new InfoResponse
{