File tree 3 files changed +22
-5
lines changed
3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -152,14 +152,20 @@ function showProblem(problem, argv) {
152
152
log . printf ( '* %s' , problem . category ) ;
153
153
log . printf ( '* %s (%s%%)' , h . prettyLevel ( problem . level ) , problem . percent . toFixed ( 2 ) ) ;
154
154
155
- if ( filename )
156
- log . printf ( '* Source Code: %s' , chalk . yellow . underline ( filename ) ) ;
155
+ if ( problem . likes )
156
+ log . printf ( '* Likes: %s' , problem . likes ) ;
157
+ if ( problem . dislikes )
158
+ log . printf ( '* Dislikes: %s' , problem . dislikes ) ;
159
+ else
160
+ log . printf ( '* Dislikes: -' ) ;
157
161
if ( problem . totalAC )
158
162
log . printf ( '* Total Accepted: %s' , problem . totalAC ) ;
159
163
if ( problem . totalSubmit )
160
164
log . printf ( '* Total Submissions: %s' , problem . totalSubmit ) ;
161
165
if ( problem . testable && problem . testcase )
162
166
log . printf ( '* Testcase Example: %s' , chalk . yellow ( util . inspect ( problem . testcase ) ) ) ;
167
+ if ( filename )
168
+ log . printf ( '* Source Code: %s' , chalk . yellow . underline ( filename ) ) ;
163
169
164
170
log . info ( ) ;
165
171
log . info ( problem . desc ) ;
Original file line number Diff line number Diff line change @@ -28,13 +28,20 @@ plugin.getProblem = function(problem, cb) {
28
28
const k = h . KEYS . problem ( problem ) ;
29
29
const _problem = cache . get ( k ) ;
30
30
if ( _problem ) {
31
- // Only hit description with html tags (<pre> always exists for presenting testcase)
32
- if ( _problem . desc . includes ( "<pre>" ) ) {
31
+ // do not hit problem without html tags in desc (<pre> always exists for presenting testcase)
32
+ if ( ! _problem . desc . includes ( "<pre>" ) ) {
33
+ log . debug ( 'cache discarded for being no longer valid: ' + k + '.json' ) ;
34
+ }
35
+ // do not hit problem without likes & dislikes (logic will be improved in new lib)
36
+ else if ( ! [ 'likes' , 'dislikes' ] . every ( p => p in _problem ) ) {
37
+ log . debug ( 'cache discarded for being too old: ' + k + '.json' ) ;
38
+ }
39
+ // cache hit
40
+ else {
33
41
log . debug ( 'cache hit: ' + k + '.json' ) ;
34
42
_ . extendOwn ( problem , _problem ) ;
35
43
return cb ( null , problem ) ;
36
44
}
37
- log . debug ( 'cache discarded for being no longer valid: ' + k + '.json' ) ;
38
45
}
39
46
40
47
plugin . next . getProblem ( problem , function ( e , _problem ) {
Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ plugin.getProblem = function(problem, cb) {
134
134
' question(titleSlug: $titleSlug) {' ,
135
135
' content' ,
136
136
' stats' ,
137
+ ' likes' ,
138
+ ' dislikes' ,
137
139
' codeDefinition' ,
138
140
' sampleTestCase' ,
139
141
' enableRunCode' ,
@@ -157,6 +159,8 @@ plugin.getProblem = function(problem, cb) {
157
159
158
160
problem . totalAC = JSON . parse ( q . stats ) . totalAccepted ;
159
161
problem . totalSubmit = JSON . parse ( q . stats ) . totalSubmission ;
162
+ problem . likes = q . likes ;
163
+ problem . dislikes = q . dislikes ;
160
164
161
165
const content = q . translatedContent ? q . translatedContent : q . content ;
162
166
// // Replace <sup/> with '^' as the power operator
You can’t perform that action at this time.
0 commit comments