@@ -41,6 +41,7 @@ public class PullRequestService : IPullRequestService
4141 static readonly Regex BranchCapture = new Regex ( @"branch\.(?<branch>.+)\.ghfvs-pr" , RegexOptions . ECMAScript ) ;
4242 static ICompiledQuery < Page < ActorModel > > readAssignableUsers ;
4343 static ICompiledQuery < Page < PullRequestListItemModel > > readPullRequests ;
44+ static ICompiledQuery < Page < PullRequestListItemModel > > readPullRequestsEnterprise ;
4445
4546 static readonly string [ ] TemplatePaths = new [ ]
4647 {
@@ -81,110 +82,120 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
8182 string after ,
8283 PullRequestStateEnum [ ] states )
8384 {
84- if ( readPullRequests == null )
85+
86+ ICompiledQuery < Page < PullRequestListItemModel > > query ;
87+
88+ if ( address . IsGitHubDotCom ( ) )
8589 {
86- if ( address . IsGitHubDotCom ( ) )
90+ if ( readPullRequests == null )
8791 {
8892 readPullRequests = new Query ( )
89- . Repository ( Var ( nameof ( owner ) ) , Var ( nameof ( name ) ) )
90- . PullRequests (
91- first : 100 ,
92- after : Var ( nameof ( after ) ) ,
93- orderBy : new IssueOrder { Direction = OrderDirection . Desc , Field = IssueOrderField . CreatedAt } ,
94- states : Var ( nameof ( states ) ) )
95- . Select ( page => new Page < PullRequestListItemModel >
96- {
97- EndCursor = page . PageInfo . EndCursor ,
98- HasNextPage = page . PageInfo . HasNextPage ,
99- TotalCount = page . TotalCount ,
100- Items = page . Nodes . Select ( pr => new ListItemAdapter
101- {
102- Id = pr . Id . Value ,
103- LastCommit = pr . Commits ( null , null , 1 , null ) . Nodes . Select ( commit =>
104- new LastCommitSummaryAdapter
105- {
106- CheckSuites = commit . Commit . CheckSuites ( null , null , null , null , null ) . AllPages ( 10 )
107- . Select ( suite => new CheckSuiteSummaryModel
108- {
109- CheckRuns = suite . CheckRuns ( null , null , null , null , null ) . AllPages ( 10 )
110- . Select ( run => new CheckRunSummaryModel
111- {
112- Conclusion = run . Conclusion . FromGraphQl ( ) ,
113- Status = run . Status . FromGraphQl ( )
114- } ) . ToList ( )
115- } ) . ToList ( ) ,
116- Statuses = commit . Commit . Status
117- . Select ( context =>
118- context . Contexts . Select ( statusContext => new StatusSummaryModel
119- {
120- State = statusContext . State . FromGraphQl ( ) ,
121- } ) . ToList ( )
122- ) . SingleOrDefault ( )
123- } ) . ToList ( ) . FirstOrDefault ( ) ,
124- Author = new ActorModel
125- {
126- Login = pr . Author . Login ,
127- AvatarUrl = pr . Author . AvatarUrl ( null ) ,
128- } ,
129- CommentCount = pr . Comments ( 0 , null , null , null ) . TotalCount ,
130- Number = pr . Number ,
131- Reviews = pr . Reviews ( null , null , null , null , null , null ) . AllPages ( ) . Select ( review => new ReviewAdapter
132- {
133- Body = review . Body ,
134- CommentCount = review . Comments ( null , null , null , null ) . TotalCount ,
135- } ) . ToList ( ) ,
136- State = pr . State . FromGraphQl ( ) ,
137- Title = pr . Title ,
138- UpdatedAt = pr . UpdatedAt ,
139- } ) . ToList ( ) ,
140- } ) . Compile ( ) ;
93+ . Repository ( Var ( nameof ( owner ) ) , Var ( nameof ( name ) ) )
94+ . PullRequests (
95+ first : 100 ,
96+ after : Var ( nameof ( after ) ) ,
97+ orderBy : new IssueOrder { Direction = OrderDirection . Desc , Field = IssueOrderField . CreatedAt } ,
98+ states : Var ( nameof ( states ) ) )
99+ . Select ( page => new Page < PullRequestListItemModel >
100+ {
101+ EndCursor = page . PageInfo . EndCursor ,
102+ HasNextPage = page . PageInfo . HasNextPage ,
103+ TotalCount = page . TotalCount ,
104+ Items = page . Nodes . Select ( pr => new ListItemAdapter
105+ {
106+ Id = pr . Id . Value ,
107+ LastCommit = pr . Commits ( null , null , 1 , null ) . Nodes . Select ( commit =>
108+ new LastCommitSummaryAdapter
109+ {
110+ CheckSuites = commit . Commit . CheckSuites ( null , null , null , null , null ) . AllPages ( 10 )
111+ . Select ( suite => new CheckSuiteSummaryModel
112+ {
113+ CheckRuns = suite . CheckRuns ( null , null , null , null , null ) . AllPages ( 10 )
114+ . Select ( run => new CheckRunSummaryModel
115+ {
116+ Conclusion = run . Conclusion . FromGraphQl ( ) ,
117+ Status = run . Status . FromGraphQl ( )
118+ } ) . ToList ( )
119+ } ) . ToList ( ) ,
120+ Statuses = commit . Commit . Status
121+ . Select ( context =>
122+ context . Contexts . Select ( statusContext => new StatusSummaryModel
123+ {
124+ State = statusContext . State . FromGraphQl ( ) ,
125+ } ) . ToList ( )
126+ ) . SingleOrDefault ( )
127+ } ) . ToList ( ) . FirstOrDefault ( ) ,
128+ Author = new ActorModel
129+ {
130+ Login = pr . Author . Login ,
131+ AvatarUrl = pr . Author . AvatarUrl ( null ) ,
132+ } ,
133+ CommentCount = pr . Comments ( 0 , null , null , null ) . TotalCount ,
134+ Number = pr . Number ,
135+ Reviews = pr . Reviews ( null , null , null , null , null , null ) . AllPages ( ) . Select ( review => new ReviewAdapter
136+ {
137+ Body = review . Body ,
138+ CommentCount = review . Comments ( null , null , null , null ) . TotalCount ,
139+ } ) . ToList ( ) ,
140+ State = pr . State . FromGraphQl ( ) ,
141+ Title = pr . Title ,
142+ UpdatedAt = pr . UpdatedAt ,
143+ } ) . ToList ( ) ,
144+ } ) . Compile ( ) ;
141145 }
142- else
146+
147+ query = readPullRequests ;
148+ }
149+ else
150+ {
151+ if ( readPullRequestsEnterprise == null )
143152 {
144- readPullRequests = new Query ( )
145- . Repository ( Var ( nameof ( owner ) ) , Var ( nameof ( name ) ) )
146- . PullRequests (
147- first : 100 ,
148- after : Var ( nameof ( after ) ) ,
149- orderBy : new IssueOrder { Direction = OrderDirection . Desc , Field = IssueOrderField . CreatedAt } ,
150- states : Var ( nameof ( states ) ) )
151- . Select ( page => new Page < PullRequestListItemModel >
152- {
153- EndCursor = page . PageInfo . EndCursor ,
154- HasNextPage = page . PageInfo . HasNextPage ,
155- TotalCount = page . TotalCount ,
156- Items = page . Nodes . Select ( pr => new ListItemAdapter
157- {
158- Id = pr . Id . Value ,
159- LastCommit = pr . Commits ( null , null , 1 , null ) . Nodes . Select ( commit =>
160- new LastCommitSummaryAdapter
161- {
162- Statuses = commit . Commit . Status
163- . Select ( context =>
164- context . Contexts . Select ( statusContext => new StatusSummaryModel
165- {
166- State = statusContext . State . FromGraphQl ( ) ,
167- } ) . ToList ( )
168- ) . SingleOrDefault ( )
169- } ) . ToList ( ) . FirstOrDefault ( ) ,
170- Author = new ActorModel
171- {
172- Login = pr . Author . Login ,
173- AvatarUrl = pr . Author . AvatarUrl ( null ) ,
174- } ,
175- CommentCount = pr . Comments ( 0 , null , null , null ) . TotalCount ,
176- Number = pr . Number ,
177- Reviews = pr . Reviews ( null , null , null , null , null , null ) . AllPages ( ) . Select ( review => new ReviewAdapter
178- {
179- Body = review . Body ,
180- CommentCount = review . Comments ( null , null , null , null ) . TotalCount ,
181- } ) . ToList ( ) ,
182- State = pr . State . FromGraphQl ( ) ,
183- Title = pr . Title ,
184- UpdatedAt = pr . UpdatedAt ,
185- } ) . ToList ( ) ,
186- } ) . Compile ( ) ;
153+ readPullRequestsEnterprise = new Query ( )
154+ . Repository ( Var ( nameof ( owner ) ) , Var ( nameof ( name ) ) )
155+ . PullRequests (
156+ first : 100 ,
157+ after : Var ( nameof ( after ) ) ,
158+ orderBy : new IssueOrder { Direction = OrderDirection . Desc , Field = IssueOrderField . CreatedAt } ,
159+ states : Var ( nameof ( states ) ) )
160+ . Select ( page => new Page < PullRequestListItemModel >
161+ {
162+ EndCursor = page . PageInfo . EndCursor ,
163+ HasNextPage = page . PageInfo . HasNextPage ,
164+ TotalCount = page . TotalCount ,
165+ Items = page . Nodes . Select ( pr => new ListItemAdapter
166+ {
167+ Id = pr . Id . Value ,
168+ LastCommit = pr . Commits ( null , null , 1 , null ) . Nodes . Select ( commit =>
169+ new LastCommitSummaryAdapter
170+ {
171+ Statuses = commit . Commit . Status
172+ . Select ( context =>
173+ context . Contexts . Select ( statusContext => new StatusSummaryModel
174+ {
175+ State = statusContext . State . FromGraphQl ( ) ,
176+ } ) . ToList ( )
177+ ) . SingleOrDefault ( )
178+ } ) . ToList ( ) . FirstOrDefault ( ) ,
179+ Author = new ActorModel
180+ {
181+ Login = pr . Author . Login ,
182+ AvatarUrl = pr . Author . AvatarUrl ( null ) ,
183+ } ,
184+ CommentCount = pr . Comments ( 0 , null , null , null ) . TotalCount ,
185+ Number = pr . Number ,
186+ Reviews = pr . Reviews ( null , null , null , null , null , null ) . AllPages ( ) . Select ( review => new ReviewAdapter
187+ {
188+ Body = review . Body ,
189+ CommentCount = review . Comments ( null , null , null , null ) . TotalCount ,
190+ } ) . ToList ( ) ,
191+ State = pr . State . FromGraphQl ( ) ,
192+ Title = pr . Title ,
193+ UpdatedAt = pr . UpdatedAt ,
194+ } ) . ToList ( ) ,
195+ } ) . Compile ( ) ;
187196 }
197+
198+ query = readPullRequestsEnterprise ;
188199 }
189200
190201 var graphql = await graphqlFactory . CreateConnection ( address ) ;
@@ -196,7 +207,7 @@ public async Task<Page<PullRequestListItemModel>> ReadPullRequests(
196207 { nameof ( states ) , states . Select ( x => ( PullRequestState ) x ) . ToList ( ) } ,
197208 } ;
198209
199- var result = await graphql . Run ( readPullRequests , vars ) ;
210+ var result = await graphql . Run ( query , vars ) ;
200211
201212 foreach ( var item in result . Items . Cast < ListItemAdapter > ( ) )
202213 {
0 commit comments