1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-09 23:00:57 -05:00

continue working on per servver topstats

This commit is contained in:
RaidMax
2019-02-26 21:25:27 -06:00
parent 03c90aeae2
commit 1182b98336
15 changed files with 96 additions and 55 deletions

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using IW4MAdmin.Plugins.Stats.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SharedLibraryCore;
@ -13,19 +14,43 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
public class StatsController : BaseController
{
[HttpGet]
public async Task<IActionResult> TopPlayersAsync()
public IActionResult TopPlayersAsync()
{
ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_TITLE"];
ViewBag.Description = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_DESC"];
ViewBag.Servers = Manager.GetServers().Select(_server => new ServerInfo() { Name = _server.Hostname, ID = _server.GetHashCode() });
return View("Index", await Plugin.Manager.GetTopStats(0, 50));
return View("Index");
}
[HttpGet]
public async Task<IActionResult> GetTopPlayersAsync(int count, int offset)
public async Task<IActionResult> GetTopPlayersAsync(int count, int offset, long? serverId = null)
{
return View("_List", await Plugin.Manager.GetTopStats(offset, count));
// this prevents empty results when we really want aggregate
if (serverId == 0)
{
serverId = null;
}
var server = Manager.GetServers().FirstOrDefault(_server => _server.EndPoint == serverId);
if (server != null)
{
serverId = await StatManager.GetIdForServer(server);
}
var results = await Plugin.Manager.GetTopStats(offset, count, serverId);
// this returns an empty result so we know to stale the loader
if (results.Count == 0 && offset > 0)
{
return Ok();
}
else
{
return View("Components/TopPlayers/_List", results);
}
}
[HttpGet]
@ -40,7 +65,7 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
where message.ServerId == serverId
where message.TimeSent >= whenLower
where message.TimeSent <= whenUpper
select new SharedLibraryCore.Dtos.ChatInfo()
select new ChatInfo()
{
ClientId = message.ClientId,
Message = message.Message,