fixed GetHashCode
fixed TopStats restrict search to minimum 3 characters
This commit is contained in:
parent
c2a3cf0d15
commit
d1283b96a1
@ -25,7 +25,21 @@ namespace IW4MAdmin
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Math.Abs($"{IP}:{Port.ToString()}".GetHashCode());
|
||||
// todo: make this better with collisions
|
||||
int id = Math.Abs($"{IP}:{Port.ToString()}".Select(a => (int)a).Sum());
|
||||
|
||||
// this is a nasty fix for get hashcode being changed
|
||||
switch(id)
|
||||
{
|
||||
case 765:
|
||||
return 886229536;
|
||||
case 760:
|
||||
return 1645744423;
|
||||
case 761:
|
||||
return 1645809959;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
override public async Task<bool> AddPlayer(Player polledPlayer)
|
||||
|
@ -1,13 +1,13 @@
|
||||
using SharedLibraryCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SharedLibraryCore;
|
||||
using SharedLibraryCore.Objects;
|
||||
using SharedLibraryCore.Services;
|
||||
using IW4MAdmin.Plugins.Stats.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using SharedLibraryCore.Database;
|
||||
namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
{
|
||||
class TopStats : Command
|
||||
@ -18,28 +18,43 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
||||
{
|
||||
var statsSvc = new GenericRepository<EFClientStatistics>();
|
||||
int serverId = E.Owner.GetHashCode();
|
||||
var iqStats = statsSvc.GetQuery(cs => cs.ServerId == serverId);
|
||||
|
||||
var topStats = iqStats.Where(cs => cs.Skill > 100)
|
||||
.Where(cs => cs.TimePlayed >= 3600)
|
||||
.Where(cs => cs.Client.Level != Player.Permission.Banned)
|
||||
.OrderByDescending(cs => cs.Skill)
|
||||
using (var db = new DatabaseContext())
|
||||
{
|
||||
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||
var topStats = await (from stats in db.Set<EFClientStatistics>()
|
||||
join client in db.Clients
|
||||
on stats.ClientId equals client.ClientId
|
||||
join alias in db.Aliases
|
||||
on client.CurrentAliasId equals alias.AliasId
|
||||
where stats.TimePlayed >= 3600
|
||||
where client.Level != Player.Permission.Banned
|
||||
where client.LastConnection >= thirtyDaysAgo
|
||||
orderby stats.Skill descending
|
||||
select new
|
||||
{
|
||||
alias.Name,
|
||||
stats.KDR,
|
||||
stats.Skill
|
||||
})
|
||||
.Take(5)
|
||||
.ToList();
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
if (!E.Message.IsBroadcastCommand())
|
||||
{
|
||||
await E.Origin.Tell("^5--Top Players--");
|
||||
|
||||
foreach (var stat in topStats)
|
||||
await E.Origin.Tell($"^3{stat.Client.Name}^7 - ^5{stat.KDR} ^7KDR | ^5{stat.Skill} ^7SKILL");
|
||||
await E.Origin.Tell($"^3{stat.Name}^7 - ^5{stat.KDR} ^7KDR | ^5{stat.Skill} ^7SKILL");
|
||||
}
|
||||
else
|
||||
{
|
||||
await E.Owner.Broadcast("^5--Top Players--");
|
||||
|
||||
foreach (var stat in topStats)
|
||||
await E.Owner.Broadcast($"^3{stat.Client.Name}^7 - ^5{stat.KDR} ^7KDR | ^5{stat.Skill} ^7SKILL");
|
||||
await E.Owner.Broadcast($"^3{stat.Name}^7 - ^5{stat.KDR} ^7KDR | ^5{stat.Skill} ^7SKILL");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,8 @@ namespace SharedLibraryCore.Database.Models
|
||||
public int LinkId { get; set; }
|
||||
[ForeignKey("LinkId")]
|
||||
public virtual EFAliasLink Link { get; set; }
|
||||
// [Index("IX_IPandName", 0, IsUnique = true)]
|
||||
//[MaxLength(24)]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
// [Index("IX_IPandName", 1, IsUnique = true)]
|
||||
// [MaxLength(24)]
|
||||
[Required]
|
||||
public int IPAddress { get; set; }
|
||||
[Required]
|
||||
|
@ -230,8 +230,8 @@ namespace SharedLibraryCore.Services
|
||||
{
|
||||
var iqClients = (from alias in context.Aliases
|
||||
.AsNoTracking()
|
||||
where alias.Name
|
||||
.Contains(name)
|
||||
where alias.Name.ToLower()
|
||||
.Contains(name.ToLower())
|
||||
join link in context.AliasLinks
|
||||
on alias.LinkId equals link.AliasLinkId
|
||||
join client in context.Clients
|
||||
|
@ -112,6 +112,7 @@
|
||||
<script type="text/javascript" src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/canvasjs.min.js"></script>
|
||||
<script type="text/javascript" src="~/js/action.js"></script>
|
||||
<script type="text/javascript" src="~/js/search.js"></script>
|
||||
</environment>
|
||||
<environment include="Production">
|
||||
<script type="text/javascript" src="~/lib/jQuery/dist/jquery.min.js"></script>
|
||||
|
@ -17,7 +17,8 @@
|
||||
"wwwroot/js/console.js",
|
||||
"wwwroot/js/penalty.js",
|
||||
"wwwroot/js/profile.js",
|
||||
"wwwroot/js/server.js"
|
||||
"wwwroot/js/server.js",
|
||||
"wwwroot/js/search.js"
|
||||
],
|
||||
// Optionally specify minification options
|
||||
"minify": {
|
||||
|
12
WebfrontCore/wwwroot/css/bootstrap-custom.css
vendored
12
WebfrontCore/wwwroot/css/bootstrap-custom.css
vendored
@ -6122,3 +6122,15 @@ form * {
|
||||
padding: 5px;
|
||||
visibility: hidden; }
|
||||
|
||||
.input-border-transition {
|
||||
-webkit-transition: border 500ms ease-out;
|
||||
-moz-transition: border 500ms ease-out;
|
||||
-o-transition: border 500ms ease-out; }
|
||||
|
||||
.input-text-danger {
|
||||
border-color: rgba(255, 69, 69, 0.85) !important; }
|
||||
|
||||
.form-control:focus {
|
||||
box-shadow: none;
|
||||
-webkit-box-shadow: none; }
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
15
WebfrontCore/wwwroot/css/bootstrap-custom.scss
vendored
15
WebfrontCore/wwwroot/css/bootstrap-custom.scss
vendored
@ -123,3 +123,18 @@ form * {
|
||||
padding: 5px;
|
||||
visibility:hidden;
|
||||
}
|
||||
|
||||
.input-border-transition {
|
||||
-webkit-transition: border 500ms ease-out;
|
||||
-moz-transition: border 500ms ease-out;
|
||||
-o-transition: border 500ms ease-out;
|
||||
}
|
||||
|
||||
.input-text-danger {
|
||||
border-color: $red !important;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
}
|
||||
|
2
WebfrontCore/wwwroot/css/global.min.css
vendored
2
WebfrontCore/wwwroot/css/global.min.css
vendored
File diff suppressed because one or more lines are too long
2
WebfrontCore/wwwroot/js/global.min.js
vendored
2
WebfrontCore/wwwroot/js/global.min.js
vendored
File diff suppressed because one or more lines are too long
22
WebfrontCore/wwwroot/js/search.js
Normal file
22
WebfrontCore/wwwroot/js/search.js
Normal file
@ -0,0 +1,22 @@
|
||||
$(document).ready(function() {
|
||||
$('.form-inline').submit(function(e) {
|
||||
if ($('#client_search').val().length < 3) {
|
||||
e.preventDefault();
|
||||
$('#client_search')
|
||||
.addClass('input-text-danger')
|
||||
.delay(25)
|
||||
.queue(function(){
|
||||
$(this).addClass('input-border-transition').dequeue();
|
||||
})
|
||||
.delay(1000)
|
||||
.queue(function() {
|
||||
$(this).removeClass('input-text-danger').dequeue();
|
||||
})
|
||||
.delay(500)
|
||||
.queue(function() {
|
||||
$(this).removeClass('input-border-transition').dequeue();
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user