diff --git a/src/BUTR.Site.NexusMods.Server/Extensions/QueryableExtensions.cs b/src/BUTR.Site.NexusMods.Server/Extensions/QueryableExtensions.cs index 1e291a83..e10f6400 100644 --- a/src/BUTR.Site.NexusMods.Server/Extensions/QueryableExtensions.cs +++ b/src/BUTR.Site.NexusMods.Server/Extensions/QueryableExtensions.cs @@ -74,7 +74,7 @@ public static async Task> PaginatedAsync(this IQueryabl where TEntity : class { var startTime = Stopwatch.GetTimestamp(); - + var count = await queryable.CountAsync(ct); return new() @@ -90,7 +90,7 @@ public static async Task> PaginatedAsync(this IQueryabl } }; } - + public static Task> PaginatedGroupedAsync(this IQueryable queryable, PaginatedQuery query, uint maxPageSize = 20, Sorting? defaultSorting = default, CancellationToken ct = default) where TEntity : class { @@ -106,20 +106,20 @@ public static Task> PaginatedGroupedAsync(this IQueryab .WithSort(sortings) .PaginatedGroupedAsync(page, pageSize, ct); } - + public static async Task> PaginatedGroupedAsync(this IQueryable queryable, uint page, uint pageSize, CancellationToken ct = default) where TEntity : class { var startTime = Stopwatch.GetTimestamp(); var response = await queryable.GroupBy(_ => 1) - .Select(x => new + .Select(x => new { PageItems = x.Skip((int) ((page - 1) * pageSize)).Take((int) pageSize).ToList(), Total = x.Count() }) .FirstAsync(cancellationToken: ct); - + return new() { StartTime = startTime, diff --git a/src/BUTR.Site.NexusMods.Server/Repositories/IRepository.cs b/src/BUTR.Site.NexusMods.Server/Repositories/IRepository.cs index ddedce4e..a050cd3b 100644 --- a/src/BUTR.Site.NexusMods.Server/Repositories/IRepository.cs +++ b/src/BUTR.Site.NexusMods.Server/Repositories/IRepository.cs @@ -135,7 +135,7 @@ public Task> PaginatedAsync(PaginatedQuery query, uint maxPageSi public Task> PaginatedAsync(Expression> projection, PaginatedQuery query, uint maxPageSize = 20, Sorting? defaultSorting = default, CancellationToken ct = default) where TProjection : class => InternalQuery .Select(projection) - //.PaginatedGroupedAsync(query, maxPageSize, defaultSorting, ct); + //.PaginatedGroupedAsync(query, maxPageSize, defaultSorting, ct); .PaginatedAsync(query, maxPageSize, defaultSorting, ct);