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:
parent
cfbacabb4a
commit
0c90d02e44
@ -5,7 +5,7 @@
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<MvcRazorExcludeRefAssembliesFromPublish>false</MvcRazorExcludeRefAssembliesFromPublish>
|
||||
<PackageId>RaidMax.IW4MAdmin.Application</PackageId>
|
||||
<Version>2.1.6</Version>
|
||||
<Version>2.1.8</Version>
|
||||
<Authors>RaidMax</Authors>
|
||||
<Company>Forever None</Company>
|
||||
<Product>IW4MAdmin</Product>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
|
@ -27,7 +27,15 @@ namespace SharedLibraryCore.Database
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> 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)
|
||||
{
|
||||
|
@ -18,13 +18,14 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jint" Version="2.11.58" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0-preview1-35029" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.1" />
|
||||
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" />
|
||||
|
@ -62,9 +62,6 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
|
||||
<PackageReference Update="Microsoft.NETCore.App" />
|
||||
<PackageReference Update="Microsoft.AspNetCore" Version="2.1.2" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user