From 3ddeb28115d6777ae1316916e7d9f53ed28a978b Mon Sep 17 00:00:00 2001 From: Vigilans Date: Fri, 19 Apr 2019 13:52:00 +0800 Subject: [PATCH 1/3] Remove redundant message when using `show -cx` --- templates/detailed.tpl | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/templates/detailed.tpl b/templates/detailed.tpl index c8ac653c..22ea0a6b 100644 --- a/templates/detailed.tpl +++ b/templates/detailed.tpl @@ -2,17 +2,5 @@ ${comment.start} ${comment.line} @lc app=${app} id=${fid} lang=${lang} ${comment.line} ${comment.line} [${fid}] ${name} -${comment.line} -${comment.line} ${link} -${comment.line} -${comment.line} ${category} -${comment.line} ${level} (${percent}%) -${comment.line} Likes: ${likes} -${comment.line} Dislikes: ${dislikes} -${comment.line} Total Accepted: ${totalAC} -${comment.line} Total Submissions: ${totalSubmit} -${comment.line} Testcase Example: ${testcase} -${comment.line} -{{ desc.forEach(function(x) { }}${comment.line} ${x} -{{ }) }}${comment.end} +${comment.end} ${code} From 2de9883c2aa65f34b5fd222db6651600f5b5bf49 Mon Sep 17 00:00:00 2001 From: Vigilans Date: Fri, 19 Apr 2019 13:52:11 +0800 Subject: [PATCH 2/3] Add file existence check in show --- lib/core.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core.js b/lib/core.js index 74362f78..8f8c807f 100644 --- a/lib/core.js +++ b/lib/core.js @@ -88,8 +88,9 @@ core.getProblem = function(keyword, cb) { if (e) return cb(e); keyword = Number(keyword) || keyword; + const metaFid = file.exist(keyword) ? Number(file.meta(keyword).id) : NaN; const problem = problems.find(function(x) { - return x.fid === keyword || x.name === keyword || x.slug === keyword; + return x.fid === keyword || x.name === keyword || x.slug === keyword || x.fid === metaFid; }); if (!problem) return cb('Problem not found!'); core.next.getProblem(problem, cb); From 2e40140a38ce439990e4cf9d492ec8cc633eb23d Mon Sep 17 00:00:00 2001 From: Vigilans Date: Fri, 19 Apr 2019 19:44:38 +0800 Subject: [PATCH 3/3] Resolve CI error --- lib/plugins/cache.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/plugins/cache.js b/lib/plugins/cache.js index 3c2194e7..c224a27e 100644 --- a/lib/plugins/cache.js +++ b/lib/plugins/cache.js @@ -28,16 +28,14 @@ plugin.getProblem = function(problem, cb) { const k = h.KEYS.problem(problem); const _problem = cache.get(k); if (_problem) { - // do not hit problem without html tags in desc (
 always exists for presenting testcase)
-    if (!_problem.desc.includes("
")) {
+    if (!_problem.desc.includes('
')) {
+      // do not hit problem without html tags in desc (
 always exists for presenting testcase)
       log.debug('cache discarded for being no longer valid: ' + k + '.json');
-    }
-    // do not hit problem without likes & dislikes (logic will be improved in new lib)
-    else if (!['likes', 'dislikes'].every(p => p in _problem)) {
+    } else if (!['likes', 'dislikes'].every(p => p in _problem)) {
+      // do not hit problem without likes & dislikes (logic will be improved in new lib)
       log.debug('cache discarded for being too old: ' + k + '.json');
-    }
-    // cache hit
-    else {
+    } else {
+      // cache hit
       log.debug('cache hit: ' + k + '.json');
       _.extendOwn(problem, _problem);
       return cb(null, problem);