Merge pull request #840 from nolt/fix-admin-panel-account-search

Search accounts in the database instead of loading all of them

(cherry picked from commit 4e806cbe64f855a765e864c0c2ff45238f487e36)
This commit is contained in:
sven-n
2026-07-22 21:57:18 +02:00
committed by Acentech Dev
parent e910845383
commit 67cc57cf31
4 changed files with 50 additions and 9 deletions

View File

@@ -80,18 +80,14 @@ public class AccountService : IDataService<Account>, ISupportDataChangedNotifica
return (await playerContext.GetAccountsOrderedByLoginNameAsync(offset, count).ConfigureAwait(false)).ToList();
}
var allAccounts = await playerContext.GetAsync<Account>().ConfigureAwait(false);
var results = allAccounts.Where(account =>
(account.LoginName != null && account.LoginName.Contains(filter, StringComparison.InvariantCultureIgnoreCase))
|| account.Characters.Any(c => c.Name != null && c.Name.Contains(filter, StringComparison.InvariantCultureIgnoreCase))
).ToList();
if (offset >= results.Count)
var results = (await playerContext.SearchAccountsAsync(filter, offset, count).ConfigureAwait(false)).ToList();
if (results.Count == 0 && offset > 0)
{
return results.Take(count).ToList();
// The filter narrowed the result set down to less entries than the current page offset - show the first page instead.
results = (await playerContext.SearchAccountsAsync(filter, 0, count).ConfigureAwait(false)).ToList();
}
return results.Skip(offset).Take(count).ToList();
return results;
}
catch
{