Skip to content

Commit 0ea7f92

Browse files
committed
Fix date sort
It was applied on page, not on the whole results.
1 parent 0325cd8 commit 0ea7f92

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

Server/Api/ReplayController.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,11 @@ public async Task<ActionResult> SearchReplays(
9898

9999
var found = ReplayParser.SearchReplays(searchMode, query, _context, page, Constants.ReplaysPerPage);
100100

101-
// Order found replays by date
102-
var foundReplays = found.Item1.OrderByDescending(r => r.Date ?? DateTime.MinValue).Take(Constants.SearchLimit).ToList();
103-
104101
var pageCount = Paginator.GetPageCount(found.Item2, Constants.ReplaysPerPage);
105102

106103
return Ok(new SearchResult()
107104
{
108-
Replays = foundReplays,
105+
Replays = found.Item1,
109106
PageCount = pageCount,
110107
CurrentPage = page,
111108
TotalReplays = found.Item2

Server/ReplayParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,10 @@ public static (List<Replay>, int) SearchReplays(SearchMode mode, string query, R
349349

350350
// Apply pagination on the database query
351351
return (queryable
352+
.Include(r => r.RoundEndPlayers)
353+
.OrderByDescending(r => r.Date ?? DateTime.MinValue).Take(Constants.SearchLimit).ToList()
352354
.Skip(page * pageSize)
353355
.Take(pageSize)
354-
.Include(r => r.RoundEndPlayers)
355356
.ToList(),
356357
totalItems);
357358
}

0 commit comments

Comments
 (0)