@@ -125,7 +125,7 @@ function showGraph(problems) {
125125 ' ' , ICONS . none + ' Remaining' ) ;
126126}
127127
128- function showCal ( ) {
128+ function showCal ( problems ) {
129129 const MONTHS = [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] ;
130130 const WEEKDAYS = [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ;
131131 const ICONS = [
@@ -142,15 +142,22 @@ function showCal() {
142142
143143 const now = moment ( ) ;
144144
145+ const SCORES = { easy : 1 , medium : 2 , hard : 5 } ;
146+ function toScore ( sum , id ) {
147+ const problem = problems . find ( x => x . fid === id ) ;
148+ if ( problem ) sum += ( SCORES [ problem . level . toLowerCase ( ) ] || 1 ) ;
149+ return sum ;
150+ }
151+
145152 // load historical stats
146153 const graph = [ ] ;
147154 const stats = require ( '../cache' ) . get ( h . KEYS . stat ) || { } ;
148155 for ( let k of _ . keys ( stats ) ) {
149- const v = ( stats [ k ] [ 'ac.set' ] || [ ] ) . length ;
150- if ( v === 0 ) continue ;
156+ const score = ( stats [ k ] [ 'ac.set' ] || [ ] ) . reduce ( toScore , 0 ) ;
157+ if ( score === 0 ) continue ;
151158
152159 const d = moment ( k , 'YYYY-MM-DD' ) ;
153- graph [ now . diff ( d , 'days' ) ] = v ;
160+ graph [ now . diff ( d , 'days' ) ] = score ;
154161 }
155162
156163 // print header
@@ -208,7 +215,7 @@ cmd.handler = function(argv) {
208215
209216 log . info ( ) ;
210217 if ( argv . graph ) showGraph ( problems ) ;
211- else if ( argv . cal ) showCal ( ) ;
218+ else if ( argv . cal ) showCal ( problems ) ;
212219 else showProgress ( problems ) ;
213220 log . info ( ) ;
214221 } ) ;
0 commit comments