diff --git a/Plugins/Stats/Commands/MostPlayedCommand.cs b/Plugins/Stats/Commands/MostPlayedCommand.cs index b93ebc28b..47328860f 100644 --- a/Plugins/Stats/Commands/MostPlayedCommand.cs +++ b/Plugins/Stats/Commands/MostPlayedCommand.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using System.Threading.Tasks; - using SharedLibraryCore; using System.Collections.Generic; using Data.Abstractions; @@ -16,11 +15,12 @@ namespace IW4MAdmin.Plugins.Stats.Commands { class MostPlayedCommand : Command { - public static async Task> GetMostPlayed(Server s, ITranslationLookup translationLookup, IDatabaseContextFactory contextFactory) + public static async Task> GetMostPlayed(Server s, ITranslationLookup translationLookup, + IDatabaseContextFactory contextFactory) { - long serverId = StatManager.GetIdForServer(s); + var serverId = StatManager.GetIdForServer(s); - List mostPlayed = new List() + var mostPlayed = new List() { $"^5--{translationLookup["PLUGINS_STATS_COMMANDS_MOSTPLAYED_TEXT"]}--" }; @@ -29,25 +29,28 @@ namespace IW4MAdmin.Plugins.Stats.Commands var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1); var iqStats = (from stats in context.Set() - join client in context.Clients - on stats.ClientId equals client.ClientId - join alias in context.Aliases - on client.CurrentAliasId equals alias.AliasId - where stats.ServerId == serverId - where client.Level != EFClient.Permission.Banned - where client.LastConnection >= thirtyDaysAgo - orderby stats.TimePlayed descending - select new - { - alias.Name, - client.TotalConnectionTime, - stats.Kills - }) - .Take(5); + join client in context.Clients + on stats.ClientId equals client.ClientId + join alias in context.Aliases + on client.CurrentAliasId equals alias.AliasId + where stats.ServerId == serverId + where client.Level != EFClient.Permission.Banned + where client.LastConnection >= thirtyDaysAgo + orderby stats.TimePlayed descending + select new + { + alias.Name, + stats.TimePlayed, + stats.Kills + }) + .Take(5); var iqList = await iqStats.ToListAsync(); - mostPlayed.AddRange(iqList.Select(stats => translationLookup["COMMANDS_MOST_PLAYED_FORMAT"].FormatExt(stats.Name, stats.Kills, (DateTime.UtcNow - DateTime.UtcNow.AddSeconds(-stats.TotalConnectionTime)).HumanizeForCurrentCulture()))); + mostPlayed.AddRange(iqList.Select((stats, index) => + $"#{index + 1} " + translationLookup["COMMANDS_MOST_PLAYED_FORMAT"].FormatExt(stats.Name, stats.Kills, + (DateTime.UtcNow - DateTime.UtcNow.AddSeconds(-stats.TimePlayed)) + .HumanizeForCurrentCulture()))); return mostPlayed; @@ -57,7 +60,7 @@ namespace IW4MAdmin.Plugins.Stats.Commands private readonly IDatabaseContextFactory _contextFactory; public MostPlayedCommand(CommandConfiguration config, ITranslationLookup translationLookup, - IDatabaseContextFactory contextFactory) : base(config, translationLookup) + IDatabaseContextFactory contextFactory) : base(config, translationLookup) { Name = "mostplayed"; Description = translationLookup["PLUGINS_STATS_COMMANDS_MOSTPLAYED_DESC"]; @@ -88,4 +91,4 @@ namespace IW4MAdmin.Plugins.Stats.Commands } } } -} +} \ No newline at end of file diff --git a/Plugins/Stats/Commands/TopStats.cs b/Plugins/Stats/Commands/TopStats.cs index 81a9a05b3..fd3bc9d3b 100644 --- a/Plugins/Stats/Commands/TopStats.cs +++ b/Plugins/Stats/Commands/TopStats.cs @@ -25,7 +25,7 @@ namespace IW4MAdmin.Plugins.Stats.Commands }; var stats = await Plugin.Manager.GetTopStats(0, 5, serverId); - var statsList = stats.Select(stats => $"^3{stats.Name}^7 - ^5{stats.KDR} ^7{translationLookup["PLUGINS_STATS_TEXT_KDR"]} | ^5{stats.Performance} ^7{translationLookup["PLUGINS_STATS_COMMANDS_PERFORMANCE"]}"); + var statsList = stats.Select((stats, index) => $"#{index + 1} ^3{stats.Name}^7 - ^5{stats.KDR} ^7{translationLookup["PLUGINS_STATS_TEXT_KDR"]} | ^5{stats.Performance} ^7{translationLookup["PLUGINS_STATS_COMMANDS_PERFORMANCE"]}"); topStatsText.AddRange(statsList);