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 cfbacabb4a
commit 0c90d02e44
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