Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 39cbef4

Browse files
committed
Add timers for ReadPullRequestDetail
Log the GetPullRequestFiles and GetPullRequestLastCommitAdapter calls.
1 parent 066ec81 commit 39cbef4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public IReadOnlyList<InlineAnnotationModel> BuildAnnotations(
9797
relativePath = relativePath.Replace("\\", "/");
9898

9999
return pullRequest.CheckSuites
100-
?.SelectMany(checkSuite => checkSuite.CheckRuns.Select(checkRun => new { checkSuite, checkRun}))
100+
?.SelectMany(checkSuite => checkSuite.CheckRuns.Select(checkRun => new { checkSuite, checkRun }))
101101
.SelectMany(arg =>
102102
arg.checkRun.Annotations
103103
.Where(annotation => annotation.Path == relativePath)
@@ -361,17 +361,21 @@ public virtual async Task<PullRequestDetailModel> ReadPullRequestDetail(HostAddr
361361
var result = await connection.Run(readPullRequest, vars);
362362

363363
var apiClient = await apiClientFactory.Create(address);
364-
var files = await apiClient.GetPullRequestFiles(owner, name, number).ToList();
365-
var lastCommitModel = await GetPullRequestLastCommitAdapter(address, owner, name, number);
366364

367-
result.Statuses = (IReadOnlyList<StatusModel>) lastCommitModel.Statuses ?? Array.Empty<StatusModel>();
365+
var files = await log.TimeAsync(nameof(apiClient.GetPullRequestFiles),
366+
async () => await apiClient.GetPullRequestFiles(owner, name, number).ToList());
367+
368+
var lastCommitModel = await log.TimeAsync(nameof(GetPullRequestLastCommitAdapter),
369+
() => GetPullRequestLastCommitAdapter(address, owner, name, number));
370+
371+
result.Statuses = (IReadOnlyList<StatusModel>)lastCommitModel.Statuses ?? Array.Empty<StatusModel>();
368372

369373
if (lastCommitModel.CheckSuites == null)
370374
{
371375
result.CheckSuites = Array.Empty<CheckSuiteModel>();
372376
}
373377
else
374-
{
378+
{
375379
result.CheckSuites = lastCommitModel.CheckSuites;
376380
foreach (var checkSuite in result.CheckSuites)
377381
{
@@ -838,8 +842,8 @@ async Task<LastCommitAdapter> GetPullRequestLastCommitAdapter(HostAddress addres
838842
commit => new LastCommitAdapter
839843
{
840844
Statuses = commit.Commit.Status == null ? null : commit.Commit.Status
841-
.Select(context => context == null
842-
? null
845+
.Select(context => context == null
846+
? null
843847
: context.Contexts
844848
.Select(statusContext => new StatusModel
845849
{
@@ -871,7 +875,7 @@ async Task<LastCommitAdapter> GetPullRequestLastCommitAdapter(HostAddress addres
871875
static void BuildPullRequestThreads(PullRequestDetailModel model)
872876
{
873877
var commentsByReplyId = new Dictionary<string, List<CommentAdapter>>();
874-
878+
875879
// Get all comments that are not replies.
876880
foreach (CommentAdapter comment in model.Reviews.SelectMany(x => x.Comments))
877881
{
@@ -961,5 +965,5 @@ class LastCommitAdapter
961965

962966
public string HeadSha { get; set; }
963967
}
964-
}
968+
}
965969
}

0 commit comments

Comments
 (0)