File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ var cmd = {
4343 . example ( chalk . yellow ( 'leetcode stat' ) , 'Show progress status' )
4444 . example ( chalk . yellow ( 'leetcode stat --no-lock' ) , 'Show progress status without locked questions' )
4545 . example ( chalk . yellow ( 'leetcode stat -t algorithms' ) , 'Show progress status of algorithms questions' )
46- . example ( chalk . yellow ( 'leetcode stat -g' ) , 'Show detailed status in graph' ) ;
46+ . example ( chalk . yellow ( 'leetcode stat -g' ) , 'Show detailed status in graph' )
47+ . example ( chalk . yellow ( 'leetcode stat -c' ) , 'Show accepted status in calendar' ) ;
4748 }
4849} ;
4950
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ function printLine() {
4444
4545cmd . handler = function ( argv ) {
4646 session . argv = argv ;
47-
4847 if ( ! fs . existsSync ( argv . filename ) )
4948 return log . error ( 'File ' + argv . filename + ' not exist!' ) ;
5049
@@ -66,8 +65,8 @@ cmd.handler = function(argv) {
6665 printLine ( result , '%d/%d cases passed (%s)' ,
6766 result . passed , result . total , result . runtime ) ;
6867
69- // show beat ratio
7068 if ( result . ok ) {
69+ session . updateStat ( 'ac' , 1 ) ;
7170 core . getSubmission ( { id : result . id } , function ( e , submission ) {
7271 if ( e || ! submission || ! submission . distributionChart )
7372 return log . warn ( 'Failed to get submission beat ratio.' ) ;
Original file line number Diff line number Diff line change 1+ var moment = require ( 'moment' ) ;
12var _ = require ( 'underscore' ) ;
23
34var cache = require ( './cache' ) ;
@@ -32,4 +33,14 @@ session.isLogin = function() {
3233 return this . getUser ( ) !== null ;
3334} ;
3435
36+ session . updateStat = function ( k , v ) {
37+ // TODO: use other storage if too many stat data
38+ var today = moment ( ) . format ( 'YYYY-MM-DD' ) ;
39+ var stats = cache . get ( h . KEYS . stat ) || { } ;
40+ var stat = stats [ today ] = stats [ today ] || { } ;
41+ stat [ k ] = stat [ k ] || 0 ;
42+ stat [ k ] += v ;
43+ cache . set ( h . KEYS . stat , stats ) ;
44+ } ;
45+
3546module . exports = session ;
You can’t perform that action at this time.
0 commit comments