@@ -2728,6 +2728,12 @@ export class GitHubApi implements Disposable {
27282728 ) : Promise < SearchedPullRequest [ ] > {
27292729 const scope = getLogScope ( ) ;
27302730
2731+ if ( configuration . get ( 'launchpad.experimental.queryUseInvolvesFilter' ) ?? false ) {
2732+ return this . searchMyInvolvedPullRequests ( provider , token , options , cancellation ) ;
2733+ }
2734+
2735+ const limit = Math . min ( 100 , configuration . get ( 'launchpad.experimental.queryLimit' ) ?? 100 ) ;
2736+
27312737 interface SearchResult {
27322738 authored : {
27332739 nodes : GitHubPullRequest [ ] ;
@@ -2751,28 +2757,28 @@ export class GitHubApi implements Disposable {
27512757 $mentioned: String!
27522758 $avatarSize: Int
27532759) {
2754- authored: search(first: 100 , query: $authored, type: ISSUE) {
2760+ authored: search(first: ${ limit } , query: $authored, type: ISSUE) {
27552761 nodes {
27562762 ...on PullRequest {
27572763 ${ gqlPullRequestFragment }
27582764 }
27592765 }
27602766 }
2761- assigned: search(first: 100 , query: $assigned, type: ISSUE) {
2767+ assigned: search(first: ${ limit } , query: $assigned, type: ISSUE) {
27622768 nodes {
27632769 ...on PullRequest {
27642770 ${ gqlPullRequestFragment }
27652771 }
27662772 }
27672773 }
2768- reviewRequested: search(first: 100 , query: $reviewRequested, type: ISSUE) {
2774+ reviewRequested: search(first: ${ limit } , query: $reviewRequested, type: ISSUE) {
27692775 nodes {
27702776 ...on PullRequest {
27712777 ${ gqlPullRequestFragment }
27722778 }
27732779 }
27742780 }
2775- mentioned: search(first: 100 , query: $mentioned, type: ISSUE) {
2781+ mentioned: search(first: ${ limit } , query: $mentioned, type: ISSUE) {
27762782 nodes {
27772783 ...on PullRequest {
27782784 ${ gqlPullRequestFragment }
@@ -2832,6 +2838,100 @@ export class GitHubApi implements Disposable {
28322838 }
28332839 }
28342840
2841+ @debug < GitHubApi [ 'searchMyInvolvedPullRequests' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
2842+ private async searchMyInvolvedPullRequests (
2843+ provider : Provider ,
2844+ token : string ,
2845+ options ?: { search ?: string ; user ?: string ; repos ?: string [ ] ; baseUrl ?: string ; avatarSize ?: number } ,
2846+ cancellation ?: CancellationToken ,
2847+ ) : Promise < SearchedPullRequest [ ] > {
2848+ const scope = getLogScope ( ) ;
2849+
2850+ const limit = Math . min ( 100 , configuration . get ( 'launchpad.experimental.queryLimit' ) ?? 100 ) ;
2851+
2852+ try {
2853+ interface SearchResult {
2854+ search : {
2855+ issueCount : number ;
2856+ nodes : GitHubPullRequest [ ] ;
2857+ } ;
2858+ viewer : {
2859+ login : string ;
2860+ } ;
2861+ }
2862+
2863+ const query = `query searchMyPullRequests(
2864+ $search: String!
2865+ $avatarSize: Int
2866+ ) {
2867+ search(first: ${ limit } , query: $search, type: ISSUE) {
2868+ issueCount
2869+ nodes {
2870+ ...on PullRequest {
2871+ ${ gqlPullRequestFragment }
2872+ }
2873+ }
2874+ }
2875+ viewer {
2876+ login
2877+ }
2878+ }` ;
2879+
2880+ let search = options ?. search ?. trim ( ) ?? '' ;
2881+
2882+ if ( options ?. user ) {
2883+ search += ` user:${ options . user } ` ;
2884+ }
2885+
2886+ if ( options ?. repos != null && options . repos . length > 0 ) {
2887+ const repo = ' repo:' ;
2888+ search += `${ repo } ${ options . repos . join ( repo ) } ` ;
2889+ }
2890+
2891+ const rsp = await this . graphql < SearchResult > (
2892+ provider ,
2893+ token ,
2894+ query ,
2895+ {
2896+ search : `${ search } is:pr is:open archived:false involves:@me` . trim ( ) ,
2897+ baseUrl : options ?. baseUrl ,
2898+ avatarSize : options ?. avatarSize ,
2899+ } ,
2900+ scope ,
2901+ cancellation ,
2902+ ) ;
2903+ if ( rsp == null ) return [ ] ;
2904+
2905+ const viewer = rsp . viewer . login ;
2906+
2907+ function toQueryResult ( pr : GitHubPullRequest ) : SearchedPullRequest {
2908+ const reasons = [ ] ;
2909+ if ( pr . author . login === viewer ) {
2910+ reasons . push ( 'authored' ) ;
2911+ }
2912+ if ( pr . assignees . nodes . some ( a => a . login === viewer ) ) {
2913+ reasons . push ( 'assigned' ) ;
2914+ }
2915+ if ( pr . reviewRequests . nodes . some ( r => r . requestedReviewer ?. login === viewer ) ) {
2916+ reasons . push ( 'review-requested' ) ;
2917+ }
2918+ if ( reasons . length === 0 ) {
2919+ reasons . push ( 'mentioned' ) ;
2920+ }
2921+
2922+ return {
2923+ pullRequest : fromGitHubPullRequest ( pr , provider ) ,
2924+ reasons : reasons ,
2925+ } ;
2926+ }
2927+
2928+ const results : SearchedPullRequest [ ] = rsp . search . nodes . map ( pr => toQueryResult ( pr ) ) ;
2929+ return results ;
2930+ } catch ( ex ) {
2931+ throw this . handleException ( ex , provider , scope ) ;
2932+ }
2933+ }
2934+
28352935 @debug < GitHubApi [ 'searchMyIssues' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
28362936 async searchMyIssues (
28372937 provider : Provider ,
0 commit comments