diff --git a/Application/Application.csproj b/Application/Application.csproj
index 1f36e5a01..45dca7973 100644
--- a/Application/Application.csproj
+++ b/Application/Application.csproj
@@ -5,7 +5,7 @@
netcoreapp2.1
false
RaidMax.IW4MAdmin.Application
- 2.1.6
+ 2.1.8
RaidMax
Forever None
IW4MAdmin
diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs
index 8e317dee9..308c0c1fb 100644
--- a/Plugins/Stats/Helpers/StatManager.cs
+++ b/Plugins/Stats/Helpers/StatManager.cs
@@ -36,13 +36,40 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
public EFClientStatistics GetClientStats(int clientId, int serverId) => Servers[serverId].PlayerStats[clientId];
+ ///
+ /// gets a ranking across all servers for given client id
+ ///
+ /// client id of the player
+ ///
+ public async Task GetClientOverallRanking(int clientId)
+ {
+ using (var context = new DatabaseContext(true))
+ {
+ var clientPerformance = await context.Set()
+ .Where(r => r.RatingHistory.ClientId == clientId)
+ .Where(r => r.ServerId == null)
+ .Where(r => r.Newest)
+ .Select(r => r.Performance)
+ .FirstOrDefaultAsync();
+
+ var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15);
+ var iqClientRating = (from rating in context.Set()
+ where rating.RatingHistory.Client.ClientId != clientId
+ where rating.ServerId == null
+ where rating.RatingHistory.Client.LastConnection > fifteenDaysAgo
+ where rating.RatingHistory.Client.Level != Player.Permission.Banned
+ where rating.Newest
+ where rating.ActivityAmount >= Plugin.Config.Configuration().TopPlayersMinPlayTime
+ where rating.Performance > clientPerformance
+ select rating.Ranking);
+ return await iqClientRating.CountAsync() + 1;
+ }
+ }
+
public async Task> GetTopStats(int start, int count)
{
- using (var context = new DatabaseContext())
+ using (var context = new DatabaseContext(true))
{
- context.ChangeTracker.AutoDetectChangesEnabled = false;
- context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
-
var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15);
var iqClientRatings = (from rating in context.Set()
where rating.ServerId == null
diff --git a/Plugins/Stats/Plugin.cs b/Plugins/Stats/Plugin.cs
index 44576c6d9..7f4eb87fc 100644
--- a/Plugins/Stats/Plugin.cs
+++ b/Plugins/Stats/Plugin.cs
@@ -131,6 +131,11 @@ namespace IW4MAdmin.Plugins.Stats
return new List()
{
+ new ProfileMeta()
+ {
+ Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_CLIENT_META_RANKING"],
+ Value = "#" + await Manager.GetClientOverallRanking(clientId),
+ },
new ProfileMeta()
{
Key = Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_TEXT_KILLS"],
diff --git a/Plugins/Stats/Web/Controllers/StatsController.cs b/Plugins/Stats/Web/Controllers/StatsController.cs
index ca80bcd2b..7d4b3f3f6 100644
--- a/Plugins/Stats/Web/Controllers/StatsController.cs
+++ b/Plugins/Stats/Web/Controllers/StatsController.cs
@@ -38,7 +38,7 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
var whenUpper = when.AddMinutes(5);
var whenLower = when.AddMinutes(-5);
- using (var ctx = new SharedLibraryCore.Database.DatabaseContext())
+ using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
{
var iqMessages = from message in ctx.Set()
where message.ServerId == serverId
@@ -52,17 +52,16 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
};
var messages = await iqMessages.ToListAsync();
- string sql = iqMessages.ToSql();
return View("_MessageContext", messages);
}
}
[HttpGet]
- // [Authorize]
+ [Authorize]
public async Task GetAutomatedPenaltyInfoAsync(int clientId)
{
- using (var ctx = new SharedLibraryCore.Database.DatabaseContext())
+ using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
{
var penaltyInfo = await ctx.Set()
.Where(s => s.ClientId == clientId)
@@ -71,19 +70,16 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
.Include(s => s.HitDestination)
.Include(s => s.CurrentViewAngle)
.Include(s => s.PredictedViewAngles)
- .OrderBy(s => new { s.When, s.Hits })
+ .OrderBy(s => s.When)
+ .ThenBy(s => s.Hits)
.ToListAsync();
- if (penaltyInfo != null)
- {
- return View("_PenaltyInfo", penaltyInfo);
- }
-
- return NotFound();
+ return View("_PenaltyInfo", penaltyInfo);
}
}
}
+#if DEBUG == true
public static class IQueryableExtensions
{
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
@@ -111,4 +107,5 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
return sql;
}
}
+#endif
}
diff --git a/SharedLibraryCore/Database/DatabaseContext.cs b/SharedLibraryCore/Database/DatabaseContext.cs
index af9885b97..e9c673624 100644
--- a/SharedLibraryCore/Database/DatabaseContext.cs
+++ b/SharedLibraryCore/Database/DatabaseContext.cs
@@ -27,7 +27,15 @@ namespace SharedLibraryCore.Database
public DatabaseContext(DbContextOptions opt) : base(opt) { }
- public DatabaseContext() { }
+ public DatabaseContext(bool disableTracking = false)
+ {
+ if (disableTracking)
+ {
+ this.ChangeTracker.AutoDetectChangesEnabled = false;
+ this.ChangeTracker.LazyLoadingEnabled = false;
+ this.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
+ }
+ }
public DatabaseContext(string connStr)
{
diff --git a/SharedLibraryCore/SharedLibraryCore.csproj b/SharedLibraryCore/SharedLibraryCore.csproj
index 4722fc270..66678d892 100644
--- a/SharedLibraryCore/SharedLibraryCore.csproj
+++ b/SharedLibraryCore/SharedLibraryCore.csproj
@@ -18,13 +18,14 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj
index c46d99eb4..d92977f7d 100644
--- a/WebfrontCore/WebfrontCore.csproj
+++ b/WebfrontCore/WebfrontCore.csproj
@@ -62,9 +62,6 @@
-
-
-