diff --git a/lib/commands/submit.js b/lib/commands/submit.js index 9deaaa82..123c121a 100644 --- a/lib/commands/submit.js +++ b/lib/commands/submit.js @@ -66,16 +66,20 @@ cmd.handler = function(argv) { if (result.ok) { session.updateStat('ac', 1); session.updateStat('ac.set', problem.fid); - if (result.runtime_percentile) - printLine(result, 'Your runtime beats %d %% of %s submissions', - result.runtime_percentile.toFixed(2), result.lang); - else - return log.warn('Failed to get runtime percentile.'); - if (result.memory && result.memory_percentile) - printLine(result, 'Your memory usage beats %d %% of %s submissions (%s)', - result.memory_percentile.toFixed(2), result.lang, result.memory); - else - return log.warn('Failed to get memory percentile.'); + + (function () { + if (result.runtime_percentile) + printLine(result, 'Your runtime beats %d %% of %s submissions', + result.runtime_percentile.toFixed(2), result.lang); + else + return log.warn('Failed to get runtime percentile.'); + if (result.memory && result.memory_percentile) + printLine(result, 'Your memory usage beats %d %% of %s submissions (%s)', + result.memory_percentile.toFixed(2), result.lang, result.memory); + else + return log.warn('Failed to get memory percentile.'); + })(); + // core.getSubmission({id: result.id}, function(e, submission) { // if (e || !submission || !submission.distributionChart) // return log.warn('Failed to get submission beat ratio.'); diff --git a/lib/plugins/cache.js b/lib/plugins/cache.js index 677c6c84..90abed93 100644 --- a/lib/plugins/cache.js +++ b/lib/plugins/cache.js @@ -28,9 +28,13 @@ plugin.getProblem = function(problem, cb) { const k = h.KEYS.problem(problem); const _problem = cache.get(k); if (_problem) { - log.debug('cache hit: ' + k + '.json'); - _.extendOwn(problem, _problem); - return cb(null, problem); + // Only hit description with html tags (
always exists for presenting testcase) + if (_problem.desc.includes("")) { + log.debug('cache hit: ' + k + '.json'); + _.extendOwn(problem, _problem); + return cb(null, problem); + } + log.debug('cache discarded for being no longer valid: ' + k + '.json'); } plugin.next.getProblem(problem, function(e, _problem) { diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js index bba96e6a..2e2ede83 100644 --- a/lib/plugins/leetcode.js +++ b/lib/plugins/leetcode.js @@ -158,10 +158,11 @@ plugin.getProblem = function(problem, cb) { problem.totalAC = JSON.parse(q.stats).totalAccepted; problem.totalSubmit = JSON.parse(q.stats).totalSubmission; - let content = q.translatedContent ? q.translatedContent : q.content; - // Replace with '^' as the power operator - content = content.replace(/<\/sup>/gm, '').replace(//gm, '^'); - problem.desc = he.decode(cheerio.load(content).root().text()); + const content = q.translatedContent ? q.translatedContent : q.content; + // // Replace with '^' as the power operator + // content = content.replace(/<\/sup>/gm, '').replace(//gm, '^'); + // problem.desc = he.decode(cheerio.load(content).root().text()); + problem.desc = content; problem.templates = JSON.parse(q.codeDefinition); problem.testcase = q.sampleTestCase;