@@ -20,16 +20,23 @@ var cmd = {
2020 default : false ,
2121 describe : 'Show graphic statistics'
2222 } )
23+ . option ( 'l' , {
24+ alias : 'lock' ,
25+ type : 'boolean' ,
26+ default : true ,
27+ describe : 'Include locked questions'
28+ } )
2329 . option ( 't' , {
2430 alias : 'tag' ,
2531 type : 'string' ,
2632 default : 'all' ,
2733 describe : 'Show statistics for given tag' ,
2834 choices : [ 'all' ] . concat ( config . sys . categories )
2935 } )
30- . example ( chalk . yellow ( 'leetcode stat' ) , 'Show summarised progress' )
31- . example ( chalk . yellow ( 'leetcode stat -t algorithms' ) , 'Show summarised progress of algorithms questions' )
32- . example ( chalk . yellow ( 'leetcode stat -g' ) , 'Show detailed status of all questions' ) ;
36+ . example ( chalk . yellow ( 'leetcode stat' ) , 'Show progress status' )
37+ . example ( chalk . yellow ( 'leetcode stat --no-lock' ) , 'Show progress status without locked questions' )
38+ . example ( chalk . yellow ( 'leetcode stat -t algorithms' ) , 'Show progress status of algorithms questions' )
39+ . example ( chalk . yellow ( 'leetcode stat -g' ) , 'Show detailed status in graph' ) ;
3340 }
3441} ;
3542
@@ -51,40 +58,27 @@ function printLine(key, done, all) {
5158 chalk . red ( bar ( '░' , n - x ) ) ) ;
5259}
5360
54- function showSummary ( problems ) {
61+ function showProgress ( problems ) {
5562 var stats = {
5663 easy : { all : 0 , ac : 0 } ,
5764 medium : { all : 0 , ac : 0 } ,
5865 hard : { all : 0 , ac : 0 }
5966 } ;
60- var statsNoLock = {
61- easy : { all : 0 , ac : 0 } ,
62- medium : { all : 0 , ac : 0 } ,
63- hard : { all : 0 , ac : 0 }
64- } ;
6567
6668 problems . forEach ( function ( problem ) {
6769 var level = problem . level . toLowerCase ( ) ;
6870 var state = problem . state . toLowerCase ( ) ;
6971
7072 if ( ! ( level in stats ) ) return ;
7173 ++ stats [ level ] . all ;
72- if ( ! problem . locked ) ++ statsNoLock [ level ] . all ;
7374
7475 if ( ! ( state in stats [ level ] ) ) return ;
7576 ++ stats [ level ] [ state ] ;
76- if ( ! problem . locked ) ++ statsNoLock [ level ] [ state ] ;
7777 } ) ;
7878
7979 printLine ( 'Easy' , stats . easy . ac , stats . easy . all ) ;
8080 printLine ( 'Medium' , stats . medium . ac , stats . medium . all ) ;
8181 printLine ( 'Hard' , stats . hard . ac , stats . hard . all ) ;
82-
83- log . info ( ) ;
84- log . info ( 'Without Locked:' ) ;
85- printLine ( 'Easy' , statsNoLock . easy . ac , statsNoLock . easy . all ) ;
86- printLine ( 'Medium' , statsNoLock . medium . ac , statsNoLock . medium . all ) ;
87- printLine ( 'Hard' , statsNoLock . hard . ac , statsNoLock . hard . all ) ;
8882}
8983
9084function showGraph ( problems ) {
@@ -143,11 +137,12 @@ cmd.handler = function(argv) {
143137 problems = _ . filter ( problems , function ( x ) { return x . category === argv . tag ; } ) ;
144138 }
145139
146- if ( argv . graph ) {
147- showGraph ( problems ) ;
148- } else {
149- showSummary ( problems ) ;
140+ if ( ! argv . lock ) {
141+ problems = _ . filter ( problems , function ( x ) { return ! x . locked ; } ) ;
150142 }
143+
144+ if ( argv . graph ) return showGraph ( problems ) ;
145+ showProgress ( problems ) ;
151146 } ) ;
152147} ;
153148
0 commit comments