@@ -3,11 +3,18 @@ import linguist from "linguist-js"
33
44/**Indepth analyzer */
55export async function indepth ( { login, data, imports, repositories, gpg} , { skipped, categories, timeout} ) {
6- return new Promise ( async ( solve , reject ) => {
6+ return new Promise ( async solve => {
7+ //Results
8+ const results = { partial :false , total :0 , lines :{ } , stats :{ } , colors :{ } , commits :0 , files :0 , missed :{ lines :0 , bytes :0 , commits :0 } , verified :{ signature :0 } }
9+
710 //Timeout
811 if ( Number . isFinite ( timeout ) ) {
912 console . debug ( `metrics/compute/${ login } /plugins > languages > timeout set to ${ timeout } m` )
10- setTimeout ( ( ) => reject ( `Reached maximum execution time of ${ timeout } m for analysis` ) , timeout * 60 * 1000 )
13+ setTimeout ( ( ) => {
14+ results . partial = true
15+ console . debug ( `metrics/compute/${ login } /plugins > languages > reached maximum execution time of ${ timeout } m for analysis` )
16+ solve ( results )
17+ } , timeout * 60 * 1000 )
1118 }
1219
1320 //GPG keys imports
@@ -35,8 +42,11 @@ export async function indepth({login, data, imports, repositories, gpg}, {skippe
3542 }
3643
3744 //Compute repositories stats from fetched repositories
38- const results = { total :0 , lines :{ } , stats :{ } , colors :{ } , commits :0 , files :0 , missed :{ lines :0 , bytes :0 , commits :0 } , verified :{ signature :0 } }
3945 for ( const repository of repositories ) {
46+ //Early break
47+ if ( results . partial )
48+ break
49+
4050 //Skip repository if asked
4151 if ( ( skipped . includes ( repository . name . toLocaleLowerCase ( ) ) ) || ( skipped . includes ( `${ repository . owner . login } /${ repository . name } ` . toLocaleLowerCase ( ) ) ) ) {
4252 console . debug ( `metrics/compute/${ login } /plugins > languages > skipped repository ${ repository . owner . login } /${ repository . name } ` )
@@ -77,16 +87,24 @@ export async function indepth({login, data, imports, repositories, gpg}, {skippe
7787
7888/**Recent languages activity */
7989export async function recent ( { login, data, imports, rest, account} , { skipped = [ ] , categories, days = 0 , load = 0 , tempdir = "recent" , timeout} ) {
80- return new Promise ( async ( solve , reject ) => {
90+ return new Promise ( async solve => {
91+ //Results
92+ const results = { partial :false , total :0 , lines :{ } , stats :{ } , colors :{ } , commits :0 , files :0 , missed :{ lines :0 , bytes :0 , commits :0 } , days}
93+
8194 //Timeout
8295 if ( Number . isFinite ( timeout ) ) {
8396 console . debug ( `metrics/compute/${ login } /plugins > languages > timeout set to ${ timeout } m` )
84- setTimeout ( ( ) => reject ( `Reached maximum execution time of ${ timeout } m for analysis` ) , timeout * 60 * 1000 )
97+ setTimeout ( ( ) => {
98+ results . partial = true
99+ console . debug ( `metrics/compute/${ login } /plugins > languages > reached maximum execution time of ${ timeout } m for analysis` )
100+ solve ( results )
101+ return
102+ } , timeout * 60 * 1000 )
85103 }
86104
87105 //Get user recent activity
88106 console . debug ( `metrics/compute/${ login } /plugins > languages > querying api` )
89- const commits = [ ] , pages = Math . ceil ( load / 100 ) , results = { total : 0 , lines : { } , stats : { } , colors : { } , commits : 0 , files : 0 , missed : { lines : 0 , bytes : 0 , commits : 0 } , days }
107+ const commits = [ ] , pages = Math . ceil ( load / 100 )
90108 try {
91109 for ( let page = 1 ; page <= pages ; page ++ ) {
92110 console . debug ( `metrics/compute/${ login } /plugins > languages > loading page ${ page } ` )
0 commit comments