Adjustments to stats to support zombie client

This commit is contained in:
RaidMax 2023-05-09 21:14:13 -05:00
parent 3c9a1f62a3
commit 108aac83a5
3 changed files with 4 additions and 3 deletions

View File

@ -181,7 +181,7 @@ public class HitCalculator : IClientStatisticCalculator
foreach (var hitInfo in new[] {attackerHitInfo, victimHitInfo})
{
if (hitInfo.MeansOfDeath == null || hitInfo.Location == null || hitInfo.Weapon == null)
if (hitInfo.MeansOfDeath == null || hitInfo.Location == null || hitInfo.Weapon == null || hitInfo.EntityId == 0)
{
_logger.LogDebug("Skipping hit because it does not contain the required data");
continue;

View File

@ -148,7 +148,7 @@ namespace Stats.Helpers
public static Expression<Func<EFClientStatistics, bool>> GetRankingFunc(int minPlayTime, TimeSpan expiration, double? zScore = null,
long? serverId = null)
{
var oldestStat = DateTimeOffset.UtcNow.Subtract(expiration);
var oldestStat = DateTime.UtcNow.Subtract(expiration);
return stats => (serverId == null || stats.ServerId == serverId) &&
stats.UpdatedAt >= oldestStat &&
stats.Client.Level != EFClient.Permission.Banned &&

View File

@ -1198,11 +1198,12 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
oldestStat = bucketConfig.RankingExpiration;
}
var oldestStateDate = DateTime.UtcNow - oldestStat;
var performances = await context.Set<EFClientStatistics>()
.AsNoTracking()
.Where(stat => stat.ClientId == clientId)
.Where(stat => stat.ServerId != serverId) // ignore the one we're currently tracking
.Where(stats => stats.UpdatedAt >= DateTimeOffset.UtcNow - oldestStat)
.Where(stats => stats.UpdatedAt >= oldestStateDate)
.Where(stats => stats.TimePlayed >= minPlayTime)
.ToListAsync();