From 4872e2e8c42af1d0f089a0fa2388d942cb976944 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 9 Oct 2019 18:51:50 -0500 Subject: [PATCH] fix issue with top stats query and client evaluation --- Plugins/Stats/Commands/TopStats.cs | 11 +++-------- Plugins/Stats/Helpers/StatManager.cs | 3 --- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Plugins/Stats/Commands/TopStats.cs b/Plugins/Stats/Commands/TopStats.cs index b56e86c1e..c0185f72f 100644 --- a/Plugins/Stats/Commands/TopStats.cs +++ b/Plugins/Stats/Commands/TopStats.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading.Tasks; using SharedLibraryCore; -using SharedLibraryCore.Services; using IW4MAdmin.Plugins.Stats.Models; using SharedLibraryCore.Database; using System.Collections.Generic; @@ -26,6 +25,7 @@ namespace IW4MAdmin.Plugins.Stats.Commands using (var db = new DatabaseContext(true)) { var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15); + int minPlayTime = Plugin.Config.Configuration().TopPlayersMinPlayTime; var iqStats = (from stats in db.Set() join client in db.Clients @@ -33,10 +33,10 @@ namespace IW4MAdmin.Plugins.Stats.Commands join alias in db.Aliases on client.CurrentAliasId equals alias.AliasId where stats.ServerId == serverId - where stats.TimePlayed >= Plugin.Config.Configuration().TopPlayersMinPlayTime + where stats.TimePlayed >= minPlayTime where client.Level != EFClient.Permission.Banned where client.LastConnection >= fifteenDaysAgo - orderby stats.Performance descending + orderby (stats.EloRating + stats.Skill) / 2.0d descending select new { stats.KDR, @@ -45,10 +45,6 @@ namespace IW4MAdmin.Plugins.Stats.Commands }) .Take(5); -#if DEBUG == true - var statsSql = iqStats.ToSql(); -#endif - var statsList = (await iqStats.ToListAsync()) .Select(stats => $"^3{stats.Name}^7 - ^5{stats.KDR} ^7{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_TEXT_KDR"]} | ^5{stats.Performance} ^7{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_PERFORMANCE"]}"); @@ -77,7 +73,6 @@ namespace IW4MAdmin.Plugins.Stats.Commands foreach (var stat in topStats) { E.Origin.Tell(stat); - } } else diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 7c168bafc..f71d29a1e 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -149,9 +149,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers TotalTimePlayed = s.Sum(c => c.TimePlayed), }); -#if DEBUG == true - var statsInfoSql = iqStatsInfo.ToSql(); -#endif var topPlayers = await iqStatsInfo.ToListAsync(); var clientRatingsDict = clientRatings.ToDictionary(r => r.ClientId);