1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 07:13:58 -05:00

implement RSS feed in auto messages for issue #53

modified automessages to use async mesthods instead of synchronous
This commit is contained in:
RaidMax
2019-02-18 19:30:38 -06:00
parent ea40f17f7b
commit cd49a9843e
10 changed files with 1574 additions and 29 deletions

View File

@ -291,32 +291,32 @@ namespace IW4MAdmin.Plugins.Stats
MetaService.AddMeta(getMessages);
string totalKills(Server server)
async Task<object> totalKills(Server server)
{
using (var ctx = new DatabaseContext(disableTracking: true))
{
long kills = ctx.Set<EFServerStatistics>().Where(s => s.Active).Sum(s => s.TotalKills);
long kills = await ctx.Set<EFServerStatistics>().Where(s => s.Active).SumAsync(s => s.TotalKills);
return kills.ToString("#,##0");
}
}
string totalPlayTime(Server server)
async Task<object> totalPlayTime(Server server)
{
using (var ctx = new DatabaseContext(disableTracking: true))
{
long playTime = ctx.Set<EFServerStatistics>().Where(s => s.Active).Sum(s => s.TotalPlayTime);
long playTime = await ctx.Set<EFServerStatistics>().Where(s => s.Active).SumAsync(s => s.TotalPlayTime);
return (playTime / 3600.0).ToString("#,##0");
}
}
string topStats(Server s)
async Task<object> topStats(Server s)
{
return String.Join(Environment.NewLine, Commands.TopStats.GetTopStats(s).Result);
return String.Join(Environment.NewLine, await Commands.TopStats.GetTopStats(s));
}
string mostPlayed(Server s)
async Task<object> mostPlayed(Server s)
{
return String.Join(Environment.NewLine, Commands.MostPlayed.GetMostPlayed(s).Result);
return String.Join(Environment.NewLine, await Commands.MostPlayed.GetMostPlayed(s));
}
manager.GetMessageTokens().Add(new MessageToken("TOTALKILLS", totalKills));