Skip to content

Commit

Permalink
Merge pull request #661 from bcgov/yj
Browse files Browse the repository at this point in the history
chore: degug log
  • Loading branch information
ychung-mot committed Sep 19, 2024
2 parents b4f9571 + 5ac41ad commit 81d27d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/StrDss.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Information",
"Default": "Debug",
"Override": {
"Microsoft": "Warning",
"System": "Warning"
Expand Down
19 changes: 19 additions & 0 deletions server/StrDss.Data/Repositories/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using StrDss.Common;
using StrDss.Data.Entities;
using StrDss.Model;
using System.Diagnostics;

namespace StrDss.Data.Repositories
{
Expand Down Expand Up @@ -35,8 +36,16 @@ public RepositoryBase(DssDbContext dbContext, IMapper mapper, ICurrentUser curre

public async Task<PagedDto<TOutput>> Page<TInput, TOutput>(IQueryable<TInput> list, int pageSize, int pageNumber, string orderBy, string direction = "", string extraSort = "")
{
var stopwatch = Stopwatch.StartNew();

var totalRecords = list.Count();

stopwatch.Stop();

_logger.LogDebug($"Get Grouped Listings (group) - Counting groups. Page Size: {pageSize}, Page Number: {pageNumber}, Time: {stopwatch.Elapsed.TotalSeconds} seconds");

stopwatch.Restart();

if (pageNumber <= 0) pageNumber = 1;

var sort = "";
Expand Down Expand Up @@ -65,6 +74,12 @@ public async Task<PagedDto<TOutput>> Page<TInput, TOutput>(IQueryable<TInput> li

var result = await pagedList.ToListAsync();

stopwatch.Stop();

_logger.LogDebug($"Get Grouped Listings (group) - Getting groups. Time: {stopwatch.Elapsed.TotalSeconds} seconds");

stopwatch.Restart();

IEnumerable<TOutput> outputList;

if (typeof(TOutput) != typeof(TInput))
Expand All @@ -85,6 +100,10 @@ public async Task<PagedDto<TOutput>> Page<TInput, TOutput>(IQueryable<TInput> li
}
};

stopwatch.Stop();

_logger.LogDebug($"Get Grouped Listings (group) - Mapping groups to DTO. Time: {stopwatch.Elapsed.TotalSeconds} seconds");

return pagedDTO;
}
}
Expand Down

0 comments on commit 81d27d7

Please sign in to comment.