@@ -38,6 +38,7 @@ export default async function({login, data, imports, q, rest, account}, {enabled
3838 //Iterate through user's repositories and retrieve languages data
3939 console . debug ( `metrics/compute/${ login } /plugins > languages > processing ${ data . user . repositories . nodes . length } repositories` )
4040 const languages = { unique, sections, details, indepth, colors :{ } , total :0 , stats :{ } , "stats.recent" :{ } }
41+ const customColors = { }
4142 for ( const repository of data . user . repositories . nodes ) {
4243 //Skip repository if asked
4344 if ( ( skipped . includes ( repository . name . toLocaleLowerCase ( ) ) ) || ( skipped . includes ( `${ repository . owner . login } /${ repository . name } ` . toLocaleLowerCase ( ) ) ) ) {
@@ -47,7 +48,10 @@ export default async function({login, data, imports, q, rest, account}, {enabled
4748 //Process repository languages
4849 for ( const { size, node :{ color, name} } of Object . values ( repository . languages . edges ) ) {
4950 languages . stats [ name ] = ( languages . stats [ name ] ?? 0 ) + size
50- languages . colors [ name ] = colors [ name . toLocaleLowerCase ( ) ] ?? color ?? "#ededed"
51+ if ( colors [ name . toLocaleLowerCase ( ) ] )
52+ customColors [ name ] = colors [ name . toLocaleLowerCase ( ) ]
53+ if ( ! languages . colors [ name ] )
54+ languages . colors [ name ] = color
5155 languages . total += size
5256 }
5357 }
@@ -58,12 +62,15 @@ export default async function({login, data, imports, q, rest, account}, {enabled
5862 if ( ( sections . includes ( "recently-used" ) ) && ( context . mode === "user" ) ) {
5963 console . debug ( `metrics/compute/${ login } /plugins > languages > using recent analyzer` )
6064 languages [ "stats.recent" ] = await recent_analyzer ( { login, data, imports, rest, account} , { skipped, categories :_recent_categories ?? categories , days :_recent_days , load :_recent_load } )
65+ Object . assign ( languages . colors , languages [ "stats.recent" ] . colors )
6166 }
6267
6368 //Indepth mode
6469 if ( indepth ) {
6570 console . debug ( `metrics/compute/${ login } /plugins > languages > switching to indepth mode (this may take some time)` )
71+ const existingColors = languages . colors
6672 Object . assign ( languages , await indepth_analyzer ( { login, data, imports, repositories} , { skipped, categories} ) )
73+ Object . assign ( languages . colors , existingColors )
6774 console . debug ( `metrics/compute/${ login } /plugins > languages > indepth analysis missed ${ languages . missed } commits` )
6875 }
6976 }
@@ -74,11 +81,14 @@ export default async function({login, data, imports, q, rest, account}, {enabled
7481 languages [ section ] = Object . entries ( stats ) . filter ( ( [ name ] ) => ! ignored . includes ( name . toLocaleLowerCase ( ) ) ) . sort ( ( [ _an , a ] , [ _bn , b ] ) => b - a ) . slice ( 0 , limit ) . map ( ( [ name , value ] ) => ( { name, value, size :value , color :languages . colors [ name ] , x :0 } ) ) . filter ( ( { value} ) => value / total > threshold )
7582 const visible = { total :Object . values ( languages [ section ] ) . map ( ( { size} ) => size ) . reduce ( ( a , b ) => a + b , 0 ) }
7683 for ( let i = 0 ; i < languages [ section ] . length ; i ++ ) {
84+ const { name} = languages [ section ] [ i ]
7785 languages [ section ] [ i ] . value /= visible . total
7886 languages [ section ] [ i ] . x = ( languages [ section ] [ i - 1 ] ?. x ?? 0 ) + ( languages [ section ] [ i - 1 ] ?. value ?? 0 )
79- languages [ section ] [ i ] . lines = lines [ languages [ section ] [ i ] . name ] ?? 0
80- if ( ( colors [ i ] ) && ( ! colors [ languages [ section ] [ i ] . name . toLocaleLowerCase ( ) ] ) )
87+ languages [ section ] [ i ] . lines = lines [ name ] ?? 0
88+ if ( ( colors [ i ] ) && ( ! colors [ name . toLocaleLowerCase ( ) ] ) )
8189 languages [ section ] [ i ] . color = colors [ i ]
90+ else
91+ languages [ section ] [ i ] . color = customColors [ name ] ?? languages . colors [ name ] ?? "#ededed"
8292 }
8393 }
8494
0 commit comments