@@ -11,42 +11,90 @@ const github = axios.create({
1111 } ,
1212} ) ;
1313
14+ // Helper function to fetch all pages of results
15+ async function fetchAllPages ( url : string , params : any = { } ) {
16+ const allResults : any [ ] = [ ] ;
17+ let page = 1 ;
18+ let hasNextPage = true ;
19+
20+ while ( hasNextPage ) {
21+ const response = await github . get ( url , {
22+ params : { ...params , per_page : 100 , page } ,
23+ } ) ;
24+
25+ allResults . push ( ...response . data ) ;
26+
27+ // Check if there are more pages
28+ hasNextPage = response . data . length === 100 ;
29+ page ++ ;
30+
31+ // Safety limit to prevent infinite loops
32+ if ( page > 50 ) break ;
33+ }
34+
35+ return allResults ;
36+ }
37+
38+ // Helper function for search endpoints (has different response structure)
39+ async function fetchAllSearchResults ( url : string , params : any = { } ) {
40+ const allResults : any [ ] = [ ] ;
41+ let page = 1 ;
42+ let hasNextPage = true ;
43+
44+ while ( hasNextPage ) {
45+ const response = await github . get ( url , {
46+ params : { ...params , per_page : 100 , page } ,
47+ } ) ;
48+
49+ allResults . push ( ...response . data . items ) ;
50+
51+ // Check if there are more pages (search API returns total_count)
52+ hasNextPage =
53+ response . data . items . length === 100 &&
54+ allResults . length < response . data . total_count ;
55+ page ++ ;
56+
57+ // GitHub search API has a limit of 1000 results, safety limit
58+ if ( page > 10 || allResults . length >= 1000 ) break ;
59+ }
60+
61+ return allResults ;
62+ }
63+
1464export async function fetchRepos ( username : string ) {
15- const response = await github . get ( `/users/ ${ username } /repos` ) ;
16- return response . data ;
65+ // Fetch all repositories (no limit)
66+ return await fetchAllPages ( `/users/ ${ username } /repos` , { sort : "updated" } ) ;
1767}
1868
1969export async function fetchIssues ( username : string , repo : string ) {
20- const res = await github . get ( `/repos/${ username } /${ repo } /issues` , {
21- params : { state : "all" , per_page : 10 } ,
70+ // Fetch all issues (no 10 item limit)
71+ const allIssues = await fetchAllPages ( `/repos/${ username } /${ repo } /issues` , {
72+ state : "all" ,
2273 } ) ;
23- return res . data . filter ( ( issue : any ) => ! issue . pull_request ) ;
74+ return allIssues . filter ( ( issue : any ) => ! issue . pull_request ) ;
2475}
2576
2677export async function fetchPRs ( username : string , repo : string ) {
27- const res = await github . get ( `/repos/${ username } /${ repo } /pulls` , {
28- params : { state : "all" , per_page : 10 } ,
78+ // Fetch all PRs (no 10 item limit)
79+ return await fetchAllPages ( `/repos/${ username } /${ repo } /pulls` , {
80+ state : "all" ,
2981 } ) ;
30- return res . data ;
3182}
3283
3384// Fetch all PRs authored by the user across all repositories
3485export async function fetchUserAuthoredPRs ( username : string ) {
35- const res = await github . get ( `/search/issues` , {
36- params : {
37- q : `type:pr author:${ username } ` ,
38- sort : "updated" ,
39- order : "desc" ,
40- per_page : 20 ,
41- } ,
86+ // Fetch all user PRs (no 20 item limit)
87+ return await fetchAllSearchResults ( `/search/issues` , {
88+ q : `type:pr author:${ username } ` ,
89+ sort : "updated" ,
90+ order : "desc" ,
4291 } ) ;
43- return res . data . items ;
4492}
4593
4694// Fetch PRs for a specific repository that includes both repo PRs and user-authored PRs from upstream
4795export async function fetchAllPRsForRepo ( username : string , repo : string ) {
4896 try {
49- // Get PRs from the user's repository
97+ // Get all PRs from the user's repository (no limits)
5098 const repoPRs = await fetchPRs ( username , repo ) ;
5199
52100 // Check if this is a fork and get the upstream repo info
@@ -55,19 +103,15 @@ export async function fetchAllPRsForRepo(username: string, repo: string) {
55103
56104 let upstreamPRs = [ ] ;
57105 if ( isForked && repoInfo . data . parent ) {
58- // Get PRs authored by the user in the upstream repository
106+ // Get all PRs authored by the user in the upstream repository (no 10 item limit)
59107 const upstreamOwner = repoInfo . data . parent . owner . login ;
60108 const upstreamRepoName = repoInfo . data . parent . name ;
61109
62- const searchRes = await github . get ( `/search/issues` , {
63- params : {
64- q : `type:pr author:${ username } repo:${ upstreamOwner } /${ upstreamRepoName } ` ,
65- sort : "updated" ,
66- order : "desc" ,
67- per_page : 10 ,
68- } ,
110+ upstreamPRs = await fetchAllSearchResults ( `/search/issues` , {
111+ q : `type:pr author:${ username } repo:${ upstreamOwner } /${ upstreamRepoName } ` ,
112+ sort : "updated" ,
113+ order : "desc" ,
69114 } ) ;
70- upstreamPRs = searchRes . data . items ;
71115 }
72116
73117 // Combine and deduplicate PRs
0 commit comments