fixed GetHashCode

fixed TopStats
restrict search to minimum 3 characters
This commit is contained in:
RaidMax 2018-04-10 01:38:18 -05:00
parent c2a3cf0d15
commit d1283b96a1
12 changed files with 114 additions and 38 deletions

View File

@ -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)

View File

@ -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");
}
}
}
}

View File

@ -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]

View File

@ -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

View File

@ -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>

View File

@ -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": {

View File

@ -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

View File

@ -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;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View 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();
});
}
});
});