Skip to content

Commit

Permalink
Fix mission order
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddasol committed Oct 19, 2023
1 parent 22e76a8 commit a3e9e87
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
3 changes: 0 additions & 3 deletions backend/api/Services/SortingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public class SortingService
{
public static void ApplySort<T>(ref IQueryable<T> missions, string orderByQueryString) where T : SortableRecord
{
if (!missions.Any())
return;

if (string.IsNullOrWhiteSpace(orderByQueryString))
{
missions = missions.OrderBy(x => x.Name);
Expand Down
8 changes: 1 addition & 7 deletions backend/api/Utilities/PagedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ public static async Task<PagedList<T>> ToPagedListAsync(
int pageSize
)
{
// Adding order by constant value 1, which does not change order of rows
// but stops the runtime warning
int totalCount = await source.CountAsync();
List<T> items;
if (source.Expression.Type is IOrderedQueryable)
items = await source.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync();
else
items = await source.OrderBy(x => 1).Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync();
var items = await source.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToListAsync();
return new PagedList<T>(items, pageNumber, pageSize, totalCount);
}
}
Expand Down

0 comments on commit a3e9e87

Please sign in to comment.