From 46e06b57ddb5af94e807df8ffa3439618c88f862 Mon Sep 17 00:00:00 2001 From: Jamie Cansdale Date: Wed, 18 Mar 2020 09:58:20 +0000 Subject: [PATCH 1/2] Use PullRequest.timelineItems instead of timeline --- .../Services/PullRequestSessionService.cs | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs b/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs index 5987d47b3d..9c369cb0a6 100644 --- a/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs +++ b/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs @@ -306,7 +306,6 @@ public virtual Task ReadPullRequestDetail(HostAddress ad async Task ReadPullRequestDetailWithResolved(HostAddress address, string owner, string name, int number, bool refresh) { - if (readPullRequestWithResolved == null) { readPullRequestWithResolved = new Query() @@ -384,22 +383,22 @@ async Task ReadPullRequestDetailWithResolved(HostAddress AvatarUrl = review.Author.AvatarUrl(null) } }).ToList(), - Timeline = pr.Timeline(null, null, null, null, null).AllPages().Select(item => item.Switch(when => - when.Commit(commit => new CommitModel + Timeline = pr.TimelineItems(null, null, null, null, null, null, null).AllPages().Select(item => item.Switch(when => + when.PullRequestCommit(commit => new CommitModel { - AbbreviatedOid = commit.AbbreviatedOid, + AbbreviatedOid = commit.Commit.AbbreviatedOid, Author = new CommitActorModel { - Name = commit.Author.Name, - Email = commit.Author.Email, - User = commit.Author.User != null ? new ActorModel + Name = commit.Commit.Author.Name, + Email = commit.Commit.Author.Email, + User = commit.Commit.Author.User != null ? new ActorModel { - Login = commit.Author.User.Login, - AvatarUrl = commit.Author.User.AvatarUrl(null), + Login = commit.Commit.Author.User.Login, + AvatarUrl = commit.Commit.Author.User.AvatarUrl(null), } : null }, - MessageHeadline = commit.MessageHeadline, - Oid = commit.Oid, + MessageHeadline = commit.Commit.MessageHeadline, + Oid = commit.Commit.Oid, }).IssueComment(comment => new CommentModel { Author = new ActorModel @@ -563,21 +562,21 @@ async Task ReadPullRequestDetailWithoutResolved(HostAddr Url = comment.Url, }).ToList(), }).ToList(), - Timeline = pr.Timeline(null, null, null, null, null).AllPages().Select(item => item.Switch(when => - when.Commit(commit => new CommitModel + Timeline = pr.TimelineItems(null, null, null, null, null, null, null).AllPages().Select(item => item.Switch(when => + when.PullRequestCommit(commit => new CommitModel { - AbbreviatedOid = commit.AbbreviatedOid, + AbbreviatedOid = commit.Commit.AbbreviatedOid, Author = new CommitActorModel { - Name = commit.Author.Name, - Email = commit.Author.Email, - User = commit.Author.User != null ? new ActorModel + Name = commit.Commit.Author.Name, + Email = commit.Commit.Author.Email, + User = commit.Commit.Author.User != null ? new ActorModel { - Login = commit.Author.User.Login, - AvatarUrl = commit.Author.User.AvatarUrl(null), + Login = commit.Commit.Author.User.Login, + AvatarUrl = commit.Commit.Author.User.AvatarUrl(null), } : null }, - MessageHeadline = commit.MessageHeadline, - Oid = commit.Oid, + MessageHeadline = commit.Commit.MessageHeadline, + Oid = commit.Commit.Oid, }).IssueComment(comment => new CommentModel { Author = new ActorModel From d66aac352d88b1c45957d5d4ec5fbf4d2417aa76 Mon Sep 17 00:00:00 2001 From: Jamie Cansdale Date: Wed, 18 Mar 2020 17:41:46 +0000 Subject: [PATCH 2/2] Only fetch IssueComment and PullRequestCommit items --- .../Services/PullRequestSessionService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs b/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs index 9c369cb0a6..7b60f9bb29 100644 --- a/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs +++ b/src/GitHub.InlineReviews/Services/PullRequestSessionService.cs @@ -306,6 +306,8 @@ public virtual Task ReadPullRequestDetail(HostAddress ad async Task ReadPullRequestDetailWithResolved(HostAddress address, string owner, string name, int number, bool refresh) { + var itemTypes = new[] { PullRequestTimelineItemsItemType.IssueComment, PullRequestTimelineItemsItemType.PullRequestCommit }; + if (readPullRequestWithResolved == null) { readPullRequestWithResolved = new Query() @@ -383,7 +385,7 @@ async Task ReadPullRequestDetailWithResolved(HostAddress AvatarUrl = review.Author.AvatarUrl(null) } }).ToList(), - Timeline = pr.TimelineItems(null, null, null, null, null, null, null).AllPages().Select(item => item.Switch(when => + Timeline = pr.TimelineItems(null, null, null, null, itemTypes, null, null).AllPages().Select(item => item.Switch(when => when.PullRequestCommit(commit => new CommitModel { AbbreviatedOid = commit.Commit.AbbreviatedOid, @@ -490,6 +492,8 @@ async Task ReadPullRequestDetailWithResolved(HostAddress async Task ReadPullRequestDetailWithoutResolved(HostAddress address, string owner, string name, int number, bool refresh) { + var itemTypes = new[] { PullRequestTimelineItemsItemType.IssueComment, PullRequestTimelineItemsItemType.PullRequestCommit }; + if (readPullRequestWithoutResolved == null) { readPullRequestWithoutResolved = new Query() @@ -562,7 +566,7 @@ async Task ReadPullRequestDetailWithoutResolved(HostAddr Url = comment.Url, }).ToList(), }).ToList(), - Timeline = pr.TimelineItems(null, null, null, null, null, null, null).AllPages().Select(item => item.Switch(when => + Timeline = pr.TimelineItems(null, null, null, null, itemTypes, null, null).AllPages().Select(item => item.Switch(when => when.PullRequestCommit(commit => new CommitModel { AbbreviatedOid = commit.Commit.AbbreviatedOid,