File tree 3 files changed +14
-3
lines changed
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ var cmd = {
43
43
. example ( chalk . yellow ( 'leetcode stat' ) , 'Show progress status' )
44
44
. example ( chalk . yellow ( 'leetcode stat --no-lock' ) , 'Show progress status without locked questions' )
45
45
. 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' ) ;
47
48
}
48
49
} ;
49
50
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ function printLine() {
44
44
45
45
cmd . handler = function ( argv ) {
46
46
session . argv = argv ;
47
-
48
47
if ( ! fs . existsSync ( argv . filename ) )
49
48
return log . error ( 'File ' + argv . filename + ' not exist!' ) ;
50
49
@@ -66,8 +65,8 @@ cmd.handler = function(argv) {
66
65
printLine ( result , '%d/%d cases passed (%s)' ,
67
66
result . passed , result . total , result . runtime ) ;
68
67
69
- // show beat ratio
70
68
if ( result . ok ) {
69
+ session . updateStat ( 'ac' , 1 ) ;
71
70
core . getSubmission ( { id : result . id } , function ( e , submission ) {
72
71
if ( e || ! submission || ! submission . distributionChart )
73
72
return log . warn ( 'Failed to get submission beat ratio.' ) ;
Original file line number Diff line number Diff line change
1
+ var moment = require ( 'moment' ) ;
1
2
var _ = require ( 'underscore' ) ;
2
3
3
4
var cache = require ( './cache' ) ;
@@ -32,4 +33,14 @@ session.isLogin = function() {
32
33
return this . getUser ( ) !== null ;
33
34
} ;
34
35
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
+
35
46
module . exports = session ;
You can’t perform that action at this time.
0 commit comments