File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,12 +9,20 @@ type UserStat = {
99export const fetchTopUsersByPullRequests = async (
1010 repo : string
1111) : Promise < UserStat [ ] > => {
12- let url = `https://api.github.com/repos/${ repo } /pulls?state=closed&per_page=100` ;
13- const userStats : { [ key : string ] : { prCount : number ; avatarUrl : string } } =
14- { } ;
12+ //* Limit to first 300 PRs only
13+ let url = `https://api.github.com/repos/${ repo } /pulls?state=closed&per_page=100&page=1` ;
14+ const userStats : { [ key : string ] : { prCount : number ; avatarUrl : string } } = { } ;
15+ let pageCount = 0 ;
16+ const MAX_PAGES = 3 ;
1517
16- while ( url ) {
17- const response = await axios . get ( url ) ;
18+ while ( url && pageCount < MAX_PAGES ) {
19+ const response = await axios . get ( url , {
20+ timeout : 5000 ,
21+ headers : {
22+ Authorization : `token ${ process . env . GITHUB_TOKEN } ` ,
23+ }
24+ } ) ;
25+ pageCount ++ ;
1826 const prData = response . data ;
1927 prData . forEach ( ( pr : any ) => {
2028 if ( pr . merged_at ) {
@@ -55,3 +63,4 @@ export const fetchTopUsersByPullRequests = async (
5563
5664 return sortedUsers ;
5765} ;
66+
You can’t perform that action at this time.
0 commit comments