mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
a ton of stuff and fix migations
This commit is contained in:
@ -23,12 +23,9 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
$"^5--{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_TOP_TEXT"]}--"
|
||||
};
|
||||
|
||||
using (var db = new DatabaseContext())
|
||||
using (var db = new DatabaseContext(true))
|
||||
{
|
||||
db.ChangeTracker.AutoDetectChangesEnabled = false;
|
||||
db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
|
||||
|
||||
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||
var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15);
|
||||
|
||||
var iqStats = (from stats in db.Set<EFClientStatistics>()
|
||||
join client in db.Clients
|
||||
@ -36,9 +33,9 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
join alias in db.Aliases
|
||||
on client.CurrentAliasId equals alias.AliasId
|
||||
where stats.ServerId == serverId
|
||||
where stats.TimePlayed >= 3600
|
||||
where stats.TimePlayed >= Plugin.Config.Configuration().TopPlayersMinPlayTime
|
||||
where client.Level != Player.Permission.Banned
|
||||
where client.LastConnection >= thirtyDaysAgo
|
||||
where client.LastConnection >= fifteenDaysAgo
|
||||
orderby stats.Performance descending
|
||||
select new
|
||||
{
|
||||
@ -48,6 +45,10 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
})
|
||||
.Take(5);
|
||||
|
||||
#if DEBUG == true
|
||||
var statsSql = iqStats.ToSql();
|
||||
#endif
|
||||
|
||||
var statsList = (await iqStats.ToListAsync())
|
||||
.Select(stats => $"^3{stats.Name}^7 - ^5{stats.KDR} ^7{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_TEXT_KDR"]} | ^5{stats.Performance} ^7{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_PERFORMANCE"]}");
|
||||
|
||||
@ -74,12 +75,18 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
if (!E.Message.IsBroadcastCommand())
|
||||
{
|
||||
foreach (var stat in topStats)
|
||||
{
|
||||
await E.Origin.Tell(stat);
|
||||
await Task.Delay(SharedLibraryCore.RCon.StaticHelpers.FloodProtectionInterval);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var stat in topStats)
|
||||
{
|
||||
await E.Owner.Broadcast(stat);
|
||||
await Task.Delay(SharedLibraryCore.RCon.StaticHelpers.FloodProtectionInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user