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

update libraries to pre release

fix remaining issue for issue #32
adds overall ranking to profile page for issue #24
This commit is contained in:
RaidMax
2018-09-04 21:07:34 -05:00
parent 8868f98dc5
commit 85f910272a
7 changed files with 62 additions and 27 deletions

View File

@ -36,13 +36,40 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
public EFClientStatistics GetClientStats(int clientId, int serverId) => Servers[serverId].PlayerStats[clientId];
/// <summary>
/// gets a ranking across all servers for given client id
/// </summary>
/// <param name="clientId">client id of the player</param>
/// <returns></returns>
public async Task<int> GetClientOverallRanking(int clientId)
{
using (var context = new DatabaseContext(true))
{
var clientPerformance = await context.Set<EFRating>()
.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<EFRating>()
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<List<TopStatsInfo>> 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<EFRating>()
where rating.ServerId == null

View File

@ -131,6 +131,11 @@ namespace IW4MAdmin.Plugins.Stats
return new List<ProfileMeta>()
{
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"],

View File

@ -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<Models.EFClientMessage>()
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<IActionResult> GetAutomatedPenaltyInfoAsync(int clientId)
{
using (var ctx = new SharedLibraryCore.Database.DatabaseContext())
using (var ctx = new SharedLibraryCore.Database.DatabaseContext(true))
{
var penaltyInfo = await ctx.Set<Models.EFACSnapshot>()
.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
}