@@ -14,21 +14,26 @@ if (document.location.hash) {
1414document . location . href = '/' ;
1515}
1616// Set these values here because they are outside of vue's scope.
17- document . title = `CoderStats(${ github_user } )` ;
18- document . getElementsByClassName ( 'brand' ) [ 0 ] . textContent = document . title ;
17+ let short_title = `CoderStats(${ github_user } )`
18+ document . title = document . title . replace ( 'CoderStats' , short_title ) ;
19+ document . getElementsByClassName ( 'brand' ) [ 0 ] . textContent = short_title ;
1920
2021let url_user = `https://api.github.com/users/${ github_user } ` ,
2122url_repos = `${ url_user } /repos?sort=pushed&per_page=100` ,
23+ url_issues = `https://api.github.com/search/issues?q=user:${ github_user } &sort=updated&order=desc` ,
2224months_short = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' . split ( ' ' ) ;
2325
2426if ( DEV ) {
2527url_user = '/data/user.json' ;
2628url_repos = '/data/repos.json' ;
29+ url_issues = '/data/issues.json' ;
2730}
2831
2932let coder = new Vue ( {
3033el :'#coder' ,
3134data :{
35+ activetab :'repos' ,
36+ latest_issues :null ,
3237repos :[ ] ,
3338response :{ } ,
3439sort_orders :{ } ,
@@ -56,6 +61,36 @@ let coder = new Vue({
5661forks :function ( ) {
5762return this . repoRanking ( 'forks_count' ) ;
5863} ,
64+ repo_types :function ( ) {
65+ let labels = [ ] ;
66+ let values = [ ] ;
67+ let types = {
68+ active_sources :0 ,
69+ archived :0 ,
70+ disabled :0 ,
71+ forked :0 ,
72+ mirrors :0
73+ } ;
74+ for ( let repo of this . repos_pushed ) {
75+ if ( repo . archived )
76+ types . archived ++ ;
77+ else if ( repo . disabled )
78+ types . disabled ++ ;
79+ else if ( repo . fork )
80+ types . forked ++ ;
81+ else if ( repo . mirror )
82+ types . mirrors ++ ;
83+ else
84+ types . active_sources ++ ;
85+ }
86+ for ( let [ label , value ] of Object . entries ( types ) ) {
87+ if ( value > 0 ) {
88+ labels . push ( label ) ;
89+ values . push ( value ) ;
90+ }
91+ }
92+ return { labels :labels , values :values } ;
93+ } ,
5994stars :function ( ) {
6095return this . repoRanking ( 'stargazers_count' ) ;
6196} ,
@@ -98,8 +133,18 @@ let coder = new Vue({
98133this . rankingGraph ( this . issues . slice ( 0 , 10 ) , 'open_issues_count' , '#issues-ranking' ) ;
99134this . rankingGraph ( this . forks . slice ( 0 , 10 ) , 'forks_count' , '#forks-ranking' ) ;
100135this . rankingGraph ( this . stars . slice ( 0 , 10 ) , 'stargazers_count' , '#stars-ranking' ) ;
136+
137+ new Chartist . Pie ( '#repo-types-chart' , {
138+ labels :this . repo_types . labels . map ( d => d . replace ( '_' , ' ' ) ) ,
139+ series :this . repo_types . values } ) ;
101140} ,
102141methods :{
142+ fetchIssues :function ( ) {
143+ this . $http . get ( url_issues ) . then ( response => {
144+ this . response . issues = response ;
145+ this . latest_issues = response . body . items ;
146+ } ) ;
147+ } ,
103148fetchRepos :function ( ) {
104149this . $http . get ( url_repos ) . then ( response => {
105150this . response . repos = response ;
@@ -129,11 +174,17 @@ let coder = new Vue({
129174return this . repos_pushed . filter ( d => d [ property ] )
130175. sort ( ( a , b ) => b [ property ] - a [ property ] ) ;
131176} ,
132- sortBy :function ( key , type = 'number' ) {
177+ showTab :function ( name ) {
178+ this . activetab = name ;
179+ if ( ! this . latest_issues ) {
180+ this . fetchIssues ( ) ;
181+ }
182+ } ,
183+ sortBy :function ( key , type = 'number' , property = 'repos' ) {
133184let default_value = type === 'string' ?'' :0 ;
134185this . sort_key = key ;
135186this . sort_orders [ key ] = ( this . sort_orders [ key ] || 1 ) * - 1 ;
136- this . repos . sort ( ( a , b ) => {
187+ this [ property ] . sort ( ( a , b ) => {
137188let x = a [ key ] || default_value ,
138189y = b [ key ] || default_value ;
139190if ( type === 'string' ) {