webfront profile loading optimizations
This commit is contained in:
parent
7ccdee7d1b
commit
3539101a40
@ -25,10 +25,10 @@ namespace Data.MigrationContext
|
||||
{
|
||||
optionsBuilder.UseNpgsql(
|
||||
"Host=127.0.0.1;Database=IW4MAdmin_Migration;Username=postgres;Password=password;",
|
||||
options => options.SetPostgresVersion(new Version("9.4")))
|
||||
options => options.SetPostgresVersion(new Version("12.9")))
|
||||
.EnableDetailedErrors(true)
|
||||
.EnableSensitiveDataLogging(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Data.Abstractions;
|
||||
using Data.Models.Client;
|
||||
using Data.Models.Client.Stats;
|
||||
using Data.Models.Server;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -195,7 +194,6 @@ namespace IW4MAdmin.Plugins.Stats
|
||||
int messageCount = 0;
|
||||
await using var ctx = _databaseContextFactory.CreateContext(enableTracking: false);
|
||||
clientStats = await ctx.Set<EFClientStatistics>().Where(c => c.ClientId == request.ClientId).ToListAsync();
|
||||
messageCount = await ctx.Set<EFClientMessage>().CountAsync(_message => _message.ClientId == request.ClientId);
|
||||
|
||||
int kills = clientStats.Sum(c => c.Kills);
|
||||
int deaths = clientStats.Sum(c => c.Deaths);
|
||||
@ -254,14 +252,6 @@ namespace IW4MAdmin.Plugins.Stats
|
||||
Column = 0,
|
||||
Order = 5,
|
||||
Type = MetaType.Information
|
||||
},
|
||||
new InformationResponse()
|
||||
{
|
||||
Key = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_PROFILE_MESSAGES"],
|
||||
Value = messageCount.ToString("#,##0", new System.Globalization.CultureInfo(Utilities.CurrentLocalization.LocalizationName)),
|
||||
Column = 1,
|
||||
Order = 4,
|
||||
Type = MetaType.Information
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -181,19 +181,36 @@ namespace SharedLibraryCore.Services
|
||||
var aliasIps = await context.Aliases.Where(alias => alias.LinkId == linkId && alias.IPAddress != null)
|
||||
.Select(alias => alias.IPAddress)
|
||||
.ToListAsync();
|
||||
|
||||
if (ip != null)
|
||||
{
|
||||
aliasIps.Add(ip);
|
||||
}
|
||||
|
||||
iqIpPenalties = context.Penalties
|
||||
.Where(penalty => aliasIps.Contains(penalty.Offender.CurrentAlias.IPAddress))
|
||||
.Where(filter);
|
||||
var clientIds = new List<int>();
|
||||
|
||||
if (aliasIps.Any())
|
||||
{
|
||||
clientIds = await context.Clients.Where(client => aliasIps.Contains(client.CurrentAlias.IPAddress))
|
||||
.Select(client => client.ClientId).ToListAsync();
|
||||
|
||||
}
|
||||
|
||||
if (clientIds.Any())
|
||||
{
|
||||
iqIpPenalties = context.Penalties.Where(penalty => clientIds.Contains(penalty.OffenderId))
|
||||
.Where(filter);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
iqIpPenalties = Enumerable.Empty<EFPenalty>().AsQueryable();
|
||||
}
|
||||
}
|
||||
|
||||
var activePenalties = (await iqLinkPenalties.ToListAsync())
|
||||
.Union(await iqIpPenalties.ToListAsync())
|
||||
.Distinct();
|
||||
var activeLinkPenalties = await iqLinkPenalties.ToListAsync();
|
||||
var activeIpPenalties = await iqIpPenalties.ToListAsync();
|
||||
var activePenalties = activeLinkPenalties.Concat(activeIpPenalties).Distinct();
|
||||
|
||||
// this is a bit more performant in memory (ordering)
|
||||
return activePenalties.OrderByDescending(p => p.When).ToList();
|
||||
@ -221,4 +238,4 @@ namespace SharedLibraryCore.Services
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user