@@ -26,6 +26,8 @@ class Form extends React.Component {
2626 search_error : false ,
2727 repo_img : "" ,
2828 repo_url : "" ,
29+ repo_top_contributors : [ ] ,
30+ top_contributors_error : false ,
2931 } ;
3032
3133 this . input1HandleChange = this . input1HandleChange . bind ( this ) ;
@@ -90,6 +92,8 @@ class Form extends React.Component {
9092 pie_data : [ ] ,
9193 repo_url : "" ,
9294 user_url : "" ,
95+ repo_top_contributors : [ ] ,
96+ top_contributors_error : false ,
9397 } ) ;
9498
9599 if ( this . state . dropdown === "user" || preset_select === "user" ) {
@@ -325,6 +329,22 @@ class Form extends React.Component {
325329 line_data : this . state . line_data . concat ( contributor_data ) ,
326330 } ) ;
327331 } ) ;
332+
333+ try {
334+ const sorted_contributions = await octokit . repos . listContributors ( {
335+ owner : input1 ,
336+ repo : input2 ,
337+ per_page : 10 ,
338+
339+ q : "contributions" ,
340+ order : "desc" ,
341+ } ) ;
342+ this . setState ( {
343+ repo_top_contributors : sorted_contributions [ "data" ] ,
344+ } ) ;
345+ } catch ( e ) {
346+ this . setState ( { top_contributors_error : true } ) ;
347+ }
328348 } catch ( e ) {
329349 this . setState ( { search_error : true } ) ;
330350 }
@@ -625,6 +645,40 @@ class Form extends React.Component {
625645 />
626646 </ div >
627647 ) }
648+ { this . state . top_contributors_error && ! this . state . search_error && (
649+ < >
650+ < br />
651+ < br />
652+ < h4 > Top 10 Contributors by Code Commits</ h4 >
653+ < p >
654+ The history or contributor list is too large to list contributors
655+ for this repository via the API.
656+ </ p >
657+ </ >
658+ ) }
659+ { this . state . repo_top_contributors . length > 0 &&
660+ ! this . state . search_error && (
661+ < div className = { styles . repos } >
662+ < br />
663+ < br />
664+ < h4 > Top 10 Contributors by Code Commits</ h4 >
665+
666+ < div className = { styles . repos_parent } >
667+ { this . state . repo_top_contributors . map ( ( contributor ) => (
668+ < div className = { styles . repos_image } >
669+ < a href = { contributor [ "url" ] } target = "_blank" >
670+ < img
671+ src = {
672+ "https://github-readme-stats.vercel.app/api?username=" +
673+ contributor [ "login" ]
674+ }
675+ />
676+ </ a >
677+ </ div >
678+ ) ) }
679+ </ div >
680+ </ div >
681+ ) }
628682 { this . state . search_error && (
629683 < div >
630684 < h4 > Error in search, try again.</ h4 >
0 commit comments