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:
@ -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
|
||||
|
@ -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"],
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user