Pools admin log lists (#11462)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -299,7 +299,7 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
|
||||
Add(type, LogImpact.Medium, ref handler);
|
||||
}
|
||||
|
||||
public async Task<List<SharedAdminLog>> All(LogFilter? filter = null)
|
||||
public async Task<List<SharedAdminLog>> All(LogFilter? filter = null, Func<List<SharedAdminLog>>? listProvider = null)
|
||||
{
|
||||
if (TrySearchCache(filter, out var results))
|
||||
{
|
||||
@@ -307,7 +307,16 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
|
||||
}
|
||||
|
||||
var initialSize = Math.Min(filter?.Limit ?? 0, 1000);
|
||||
var list = new List<SharedAdminLog>(initialSize);
|
||||
List<SharedAdminLog> list;
|
||||
if (listProvider != null)
|
||||
{
|
||||
list = listProvider();
|
||||
list.EnsureCapacity(initialSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
list = new List<SharedAdminLog>(initialSize);
|
||||
}
|
||||
|
||||
await foreach (var log in _db.GetAdminLogs(filter).WithCancellation(filter?.CancellationToken ?? default))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user