optimize client searching

This commit is contained in:
RaidMax 2022-06-16 18:44:49 -05:00
parent fbf424c77d
commit a92f9fc29c

View File

@ -853,15 +853,16 @@ namespace SharedLibraryCore.Services
else else
{ {
iqClients = iqClients.Where(_client => networkId == _client.NetworkId || iqClients = iqClients.Where(client => networkId == client.NetworkId || linkIds.Contains(client.AliasLinkId));
linkIds.Contains(_client.AliasLinkId) }
|| !_appConfig.EnableImplicitAccountLinking &&
_client.CurrentAlias.IPAddress != null && if (ipAddress is not null && !_appConfig.EnableImplicitAccountLinking)
_client.CurrentAlias.IPAddress == ipAddress); {
iqClients = iqClients.Union(context.Clients.Where(client => client.CurrentAlias.IPAddress == ipAddress));
} }
// we want to project our results // we want to project our results
var iqClientProjection = iqClients.OrderByDescending(_client => _client.LastConnection) var iqClientProjection = iqClients.OrderByDescending(client => client.LastConnection)
.Select(client => new PlayerInfo .Select(client => new PlayerInfo
{ {
Name = client.CurrentAlias.Name, Name = client.CurrentAlias.Name,
@ -878,7 +879,9 @@ namespace SharedLibraryCore.Services
// this is so we don't try to evaluate this in the linq to entities query // this is so we don't try to evaluate this in the linq to entities query
foreach (var client in clients) foreach (var client in clients)
{
client.Level = ((Permission)client.LevelInt).ToLocalizedLevelName(); client.Level = ((Permission)client.LevelInt).ToLocalizedLevelName();
}
return clients; return clients;
} }