Skip to content

Commit

Permalink
Include better timing for debugging purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simyon264 committed Apr 11, 2024
1 parent 50469b1 commit 561aedc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Server/ReplayParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System.Diagnostics;
using System.Globalization;
using System.IO.Compression;
using System.Text.RegularExpressions;
using HtmlAgilityPack;
Expand Down Expand Up @@ -296,8 +297,10 @@ public static HttpClient CreateHttpClient()
/// </exception>
public static (List<Replay>, int) SearchReplays(SearchMode mode, string query, ReplayDbContext context, int page, int pageSize)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
var queryable = context.Replays.AsQueryable();

IIncludableQueryable<Player, Replay?>? players;
IQueryable<int?>? replayIds;
switch (mode)
Expand Down Expand Up @@ -349,12 +352,16 @@ public static (List<Replay>, int) SearchReplays(SearchMode mode, string query, R
var totalItems = queryable.Count();

// Apply pagination on the database query
return (queryable
var list = (queryable
.Include(r => r.RoundEndPlayers)
.OrderByDescending(r => r.Date ?? DateTime.MinValue).Take(Constants.SearchLimit).ToList()
.Skip(page * pageSize)
.Take(pageSize)
.ToList(),
totalItems);

stopWatch.Stop();
Log.Information("Search took " + stopWatch.ElapsedMilliseconds + "ms.");
return list;
}
}

0 comments on commit 561aedc

Please sign in to comment.