Skip to content

Commit

Permalink
optimize client searching
Browse files Browse the repository at this point in the history
  • Loading branch information
RaidMax committed Jun 16, 2022
1 parent c2353f5 commit 7be9ecc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions SharedLibraryCore/Services/ClientService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -853,15 +853,16 @@ public async Task<IList<PlayerInfo>> FindClientsByIdentifier(string identifier)

else
{
iqClients = iqClients.Where(_client => networkId == _client.NetworkId ||
linkIds.Contains(_client.AliasLinkId)
|| !_appConfig.EnableImplicitAccountLinking &&
_client.CurrentAlias.IPAddress != null &&
_client.CurrentAlias.IPAddress == ipAddress);
iqClients = iqClients.Where(client => networkId == client.NetworkId || linkIds.Contains(client.AliasLinkId));
}

if (ipAddress is not null && !_appConfig.EnableImplicitAccountLinking)
{
iqClients = iqClients.Union(context.Clients.Where(client => client.CurrentAlias.IPAddress == ipAddress));
}

// we want to project our results
var iqClientProjection = iqClients.OrderByDescending(_client => _client.LastConnection)
var iqClientProjection = iqClients.OrderByDescending(client => client.LastConnection)
.Select(client => new PlayerInfo
{
Name = client.CurrentAlias.Name,
Expand All @@ -878,7 +879,9 @@ public async Task<IList<PlayerInfo>> FindClientsByIdentifier(string identifier)

// this is so we don't try to evaluate this in the linq to entities query
foreach (var client in clients)
{
client.Level = ((Permission)client.LevelInt).ToLocalizedLevelName();
}

return clients;
}
Expand Down

0 comments on commit 7be9ecc

Please sign in to comment.