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()
|
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)
|
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.Objects;
|
||||||
using SharedLibraryCore.Services;
|
using SharedLibraryCore.Services;
|
||||||
using IW4MAdmin.Plugins.Stats.Models;
|
using IW4MAdmin.Plugins.Stats.Models;
|
||||||
using System;
|
using SharedLibraryCore.Database;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace IW4MAdmin.Plugins.Stats.Commands
|
namespace IW4MAdmin.Plugins.Stats.Commands
|
||||||
{
|
{
|
||||||
class TopStats : Command
|
class TopStats : Command
|
||||||
@ -18,28 +18,43 @@ namespace IW4MAdmin.Plugins.Stats.Commands
|
|||||||
{
|
{
|
||||||
var statsSvc = new GenericRepository<EFClientStatistics>();
|
var statsSvc = new GenericRepository<EFClientStatistics>();
|
||||||
int serverId = E.Owner.GetHashCode();
|
int serverId = E.Owner.GetHashCode();
|
||||||
var iqStats = statsSvc.GetQuery(cs => cs.ServerId == serverId);
|
|
||||||
|
|
||||||
var topStats = iqStats.Where(cs => cs.Skill > 100)
|
using (var db = new DatabaseContext())
|
||||||
.Where(cs => cs.TimePlayed >= 3600)
|
{
|
||||||
.Where(cs => cs.Client.Level != Player.Permission.Banned)
|
var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1);
|
||||||
.OrderByDescending(cs => cs.Skill)
|
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)
|
.Take(5)
|
||||||
.ToList();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
if (!E.Message.IsBroadcastCommand())
|
if (!E.Message.IsBroadcastCommand())
|
||||||
{
|
{
|
||||||
await E.Origin.Tell("^5--Top Players--");
|
await E.Origin.Tell("^5--Top Players--");
|
||||||
|
|
||||||
foreach (var stat in topStats)
|
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
|
else
|
||||||
{
|
{
|
||||||
await E.Owner.Broadcast("^5--Top Players--");
|
await E.Owner.Broadcast("^5--Top Players--");
|
||||||
|
|
||||||
foreach (var stat in topStats)
|
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; }
|
public int LinkId { get; set; }
|
||||||
[ForeignKey("LinkId")]
|
[ForeignKey("LinkId")]
|
||||||
public virtual EFAliasLink Link { get; set; }
|
public virtual EFAliasLink Link { get; set; }
|
||||||
// [Index("IX_IPandName", 0, IsUnique = true)]
|
|
||||||
//[MaxLength(24)]
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
// [Index("IX_IPandName", 1, IsUnique = true)]
|
|
||||||
// [MaxLength(24)]
|
|
||||||
[Required]
|
[Required]
|
||||||
public int IPAddress { get; set; }
|
public int IPAddress { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
@ -230,8 +230,8 @@ namespace SharedLibraryCore.Services
|
|||||||
{
|
{
|
||||||
var iqClients = (from alias in context.Aliases
|
var iqClients = (from alias in context.Aliases
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
where alias.Name
|
where alias.Name.ToLower()
|
||||||
.Contains(name)
|
.Contains(name.ToLower())
|
||||||
join link in context.AliasLinks
|
join link in context.AliasLinks
|
||||||
on alias.LinkId equals link.AliasLinkId
|
on alias.LinkId equals link.AliasLinkId
|
||||||
join client in context.Clients
|
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="~/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="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/action.js"></script>
|
||||||
|
<script type="text/javascript" src="~/js/search.js"></script>
|
||||||
</environment>
|
</environment>
|
||||||
<environment include="Production">
|
<environment include="Production">
|
||||||
<script type="text/javascript" src="~/lib/jQuery/dist/jquery.min.js"></script>
|
<script type="text/javascript" src="~/lib/jQuery/dist/jquery.min.js"></script>
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
"wwwroot/js/console.js",
|
"wwwroot/js/console.js",
|
||||||
"wwwroot/js/penalty.js",
|
"wwwroot/js/penalty.js",
|
||||||
"wwwroot/js/profile.js",
|
"wwwroot/js/profile.js",
|
||||||
"wwwroot/js/server.js"
|
"wwwroot/js/server.js",
|
||||||
|
"wwwroot/js/search.js"
|
||||||
],
|
],
|
||||||
// Optionally specify minification options
|
// Optionally specify minification options
|
||||||
"minify": {
|
"minify": {
|
||||||
|
12
WebfrontCore/wwwroot/css/bootstrap-custom.css
vendored
12
WebfrontCore/wwwroot/css/bootstrap-custom.css
vendored
@ -6122,3 +6122,15 @@ form * {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
visibility: hidden; }
|
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;
|
padding: 5px;
|
||||||
visibility:hidden;
|
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…
x
Reference in New Issue
Block a user