File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,31 +8,14 @@ async function getGitStats(username) {
88
99 const repos = await reposResponse . json ( ) ;
1010
11- // Use Promise.all to make requests in parallel
12- const commitCounts = await Promise . all (
13- repos . map ( async ( repo ) => {
14- try {
15- const response = await fetch ( `https://api.github.com/repos/${ username } /${ repo . name } /commits?author=${ username } &per_page=1` ) ;
16-
17- if ( response . ok ) {
18- const linkHeader = response . headers . get ( 'link' ) ;
19- if ( linkHeader ) {
20- const match = linkHeader . match ( / p a g e = ( \d + ) > ; r e l = " l a s t " / ) ;
21- return match ? parseInt ( match [ 1 ] ) : 1 ;
22- } else {
23- const commits = await response . json ( ) ;
24- return commits . length ;
25- }
26- }
27- return 0 ;
28- } catch ( error ) {
29- console . warn ( `Failed to fetch commits for ${ repo . name } :` , error ) ;
30- return 0 ;
31- }
32- } )
33- ) ;
34-
35- const totalCommits = commitCounts . reduce ( ( sum , count ) => sum + count , 0 ) ;
11+ const commitsResponse = await fetch ( `https://api.github.com/search/commits?q=author:${ username } &per_page=1` ) ;
12+
13+ if ( ! commitsResponse . ok ) {
14+ throw new Error ( `Failed to fetch commits: ${ commitsResponse . status } ` ) ;
15+ }
16+
17+ const commitsData = await commitsResponse . json ( ) ;
18+ const totalCommits = commitsData . total_count ;
3619
3720 return {
3821 commitCount : totalCommits ,
Original file line number Diff line number Diff line change 1- {{ len (where (where site.RegularPages "Section" "posts") "Params.unlisted" "ne" true) }}
1+ {{ len (where (where site.RegularPages "Section" "posts") "Params.unlisted" "ne" true) - }}
You can’t perform that action at this time.
0 commit comments