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

@ -10,7 +10,6 @@ using Data.Models.Client.Stats;
using IW4MAdmin.Plugins.Stats.Helpers;
using SharedLibraryCore.Configuration;
using SharedLibraryCore.Interfaces;
using static SharedLibraryCore.Server;
namespace WebfrontCore.ViewComponents
{
@ -28,19 +27,20 @@ namespace WebfrontCore.ViewComponents
_defaultSettings = defaultSettings;
}
public IViewComponentResult Invoke(Game? game)
public IViewComponentResult Invoke(Reference.Game? game)
{
if (game.HasValue)
{
ViewBag.Maps = _defaultSettings.Maps.FirstOrDefault(map => map.Game == game)?.Maps.ToList() ??
new List<Map>();
ViewBag.Maps = _defaultSettings.Maps?.FirstOrDefault(map => map.Game == (Server.Game)game)?.Maps
?.ToList() ?? new List<Map>();
}
else
{
ViewBag.Maps = _defaultSettings.Maps.SelectMany(maps => maps.Maps).ToList();
ViewBag.Maps = _defaultSettings.Maps?.SelectMany(maps => maps.Maps).ToList();
}
var servers = Program.Manager.GetServers().Where(server => !game.HasValue || server.GameName == game);
var servers = Program.Manager.GetServers()
.Where(server => game is null || server.GameName == (Server.Game)game);
var serverInfo = new List<ServerInfo>();