mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-12 08:08:06 -05:00
more updates to top stats page
This commit is contained in:
@ -53,7 +53,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||
var iqClientRatings = (from rating in context.Set<EFRating>()
|
||||
#if !DEBUG
|
||||
where rating.RatingHistory.Client.TotalConnectionTime > 3600
|
||||
where rating.ActivityAmount > 3600
|
||||
#endif
|
||||
where rating.RatingHistory.Client.Level != Player.Permission.Banned
|
||||
where rating.RatingHistory.Client.LastConnection > thirtyDaysAgo
|
||||
@ -106,6 +106,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
LastSeen = Utilities.GetTimePassed(clientRatingsDict[s.ClientId].LastConnection, false),
|
||||
Name = clientRatingsDict[s.ClientId].Name,
|
||||
Performance = Math.Round(clientRatingsDict[s.ClientId].Performance, 2),
|
||||
RatingChange = clientRatingsDict[s.ClientId].Ratings.First().Ranking - clientRatingsDict[s.ClientId].Ratings.Last().Ranking,
|
||||
PerformanceHistory = clientRatingsDict[s.ClientId].Ratings.Count() > 1 ?
|
||||
clientRatingsDict[s.ClientId].Ratings.Select(r => r.Performance).ToList() :
|
||||
new List<double>() { clientRatingsDict[s.ClientId].Performance, clientRatingsDict[s.ClientId].Performance },
|
||||
@ -559,7 +560,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
|
||||
// update their performance
|
||||
#if !DEBUG
|
||||
if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >= 10)
|
||||
if ((DateTime.UtcNow - attackerStats.LastStatHistoryUpdate).TotalMinutes >= 2.5)
|
||||
#endif
|
||||
{
|
||||
await UpdateStatHistory(attacker, attackerStats);
|
||||
@ -620,16 +621,20 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
ctx.Update(clientHistory);
|
||||
}
|
||||
|
||||
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||
// get the client ranking for the current server
|
||||
int individualClientRanking = await ctx.Set<EFRating>()
|
||||
.Where(c => c.ServerId == clientStats.ServerId)
|
||||
.Where(r => r.RatingHistory.Client.Level != Player.Permission.Banned)
|
||||
.Where(r => r.ActivityAmount > 3600)
|
||||
.Where(r => r.RatingHistory.Client.LastConnection > thirtyDaysAgo)
|
||||
.Where(c => c.RatingHistory.ClientId != client.ClientId)
|
||||
.Where(r => r.Newest)
|
||||
.Where(c => c.Performance > clientStats.Performance)
|
||||
.CountAsync() + 1;
|
||||
|
||||
// limit max history per server to 30
|
||||
if (clientHistory.Ratings.Count(r => r.ServerId == clientStats.ServerId) >= 30)
|
||||
// limit max history per server to 40
|
||||
if (clientHistory.Ratings.Count(r => r.ServerId == clientStats.ServerId) >= 40)
|
||||
{
|
||||
var ratingToRemove = clientHistory.Ratings.First(r => r.ServerId == clientStats.ServerId);
|
||||
ctx.Entry(ratingToRemove).State = EntityState.Deleted;
|
||||
@ -653,6 +658,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
Newest = true,
|
||||
ServerId = clientStats.ServerId,
|
||||
RatingHistoryId = clientHistory.RatingHistoryId,
|
||||
ActivityAmount = currentServerTotalPlaytime
|
||||
});
|
||||
|
||||
// get other server stats
|
||||
@ -667,18 +673,18 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
// weight the overall performance based on play time
|
||||
var performanceAverage = clientStatsList.Sum(p => (p.Performance * p.TimePlayed)) / clientStatsList.Sum(p => p.TimePlayed);
|
||||
|
||||
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||
int overallClientRanking = await ctx.Set<EFRating>()
|
||||
.Where(r => r.RatingHistory.Client.Level != Player.Permission.Banned)
|
||||
.Where(r => r.RatingHistory.Client.TotalConnectionTime > 3600)
|
||||
.Where(r => r.ActivityAmount > 3600)
|
||||
.Where(r => r.RatingHistory.Client.LastConnection > thirtyDaysAgo)
|
||||
.Where(r => r.RatingHistory.ClientId != client.ClientId)
|
||||
.Where(r => r.ServerId == null)
|
||||
.Where(r => r.Newest)
|
||||
.Where(r => r.Performance > performanceAverage)
|
||||
.CountAsync() + 1;
|
||||
|
||||
// limit max average history to 30
|
||||
if (clientHistory.Ratings.Count(r => r.ServerId == null) >= 30)
|
||||
// limit max average history to 40
|
||||
if (clientHistory.Ratings.Count(r => r.ServerId == null) >= 40)
|
||||
{
|
||||
var ratingToRemove = clientHistory.Ratings.First(r => r.ServerId == null);
|
||||
ctx.Entry(ratingToRemove).State = EntityState.Deleted;
|
||||
@ -701,7 +707,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
|
||||
Performance = performanceAverage,
|
||||
Ranking = overallClientRanking,
|
||||
ServerId = null,
|
||||
RatingHistoryId = clientHistory.RatingHistoryId
|
||||
RatingHistoryId = clientHistory.RatingHistoryId,
|
||||
ActivityAmount = clientStatsList.Sum(s => s.TimePlayed)
|
||||
});
|
||||
|
||||
await ctx.SaveChangesAsync();
|
||||
|
@ -25,5 +25,7 @@ namespace IW4MAdmin.Plugins.Stats.Models
|
||||
[Required]
|
||||
// indicates if the rating is the latest
|
||||
public bool Newest { get; set; }
|
||||
[Required]
|
||||
public int ActivityAmount { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace IW4MAdmin.Plugins.Stats.Web.Controllers
|
||||
ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_TITLE"];
|
||||
ViewBag.Description = Utilities.CurrentLocalization.LocalizationIndex.Set["WEBFRONT_STATS_INDEX_DESC"];
|
||||
|
||||
return View("Index", await Plugin.Manager.GetTopStats(0, 25));
|
||||
return View("Index", await Plugin.Manager.GetTopStats(0, 10));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
@ -16,6 +16,7 @@ namespace IW4MAdmin.Plugins.Stats.Web.Dtos
|
||||
public string LastSeen { get; set; }
|
||||
public int Kills { get; set; }
|
||||
public int Deaths { get; set; }
|
||||
public int RatingChange { get; set; }
|
||||
public List<double> PerformanceHistory { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,26 @@
|
||||
{
|
||||
<div class="row ml-0 mr-0 pt-2 pb-2">
|
||||
<div class="col-md-4 text-md-left text-center">
|
||||
<h2 class="text-muted">#@stat.Ranking — @Html.ActionLink(stat.Name, "ProfileAsync", "Client", new { id = stat.ClientId })</h2>
|
||||
<div class="h2 d-flex flex-row justify-content-center justify-content-md-start align-items-center">
|
||||
<div class="text-muted pr-1">#@stat.Ranking</div>
|
||||
@if (stat.RatingChange > 0)
|
||||
{
|
||||
<div class="d-flex flex-column text-center">
|
||||
<div class="oi oi-caret-top text-success client-rating-change-up"></div>
|
||||
<div class="client-rating-change-amount text-success">@stat.RatingChange</div>
|
||||
</div>
|
||||
}
|
||||
@if (stat.RatingChange < 0)
|
||||
{
|
||||
<div class="d-flex flex-column text-center">
|
||||
<div class="client-rating-change-amount client-rating-change-amount-down text-danger">@Math.Abs(stat.RatingChange)</div>
|
||||
<div class="oi oi-caret-bottom text-danger client-rating-change-down"></div>
|
||||
</div>
|
||||
}
|
||||
<span class="text-muted pl-1 pr-1" style="font-size: 1.25rem;">—</span>
|
||||
@Html.ActionLink(stat.Name, "ProfileAsync", "Client", new { id = stat.ClientId })
|
||||
</div>
|
||||
|
||||
<span class="text-primary">@stat.Performance</span><span class="text-muted"> @loc["PLUGINS_STATS_COMMANDS_PERFORMANCE"]</span><br />
|
||||
<span class="text-primary">@stat.KDR</span><span class="text-muted"> @loc["PLUGINS_STATS_TEXT_KDR"]</span>
|
||||
<span class="text-primary">@stat.Kills</span><span class="text-muted"> @loc["PLUGINS_STATS_TEXT_KILLS"]</span>
|
||||
@ -46,4 +65,4 @@
|
||||
<img src="/images/icons/@rankIcon(stat.Performance)" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user