Skip to content

Bug fix & Prepare for preview markdown webview #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions lib/commands/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
10 changes: 7 additions & 3 deletions lib/plugins/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<pre> always exists for presenting testcase)
if (_problem.desc.includes("<pre>")) {
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) {
Expand Down
9 changes: 5 additions & 4 deletions lib/plugins/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sup/> with '^' as the power operator
content = content.replace(/<\/sup>/gm, '').replace(/<sup>/gm, '^');
problem.desc = he.decode(cheerio.load(content).root().text());
const content = q.translatedContent ? q.translatedContent : q.content;
// // Replace <sup/> with '^' as the power operator
// content = content.replace(/<\/sup>/gm, '').replace(/<sup>/gm, '^');
// problem.desc = he.decode(cheerio.load(content).root().text());
problem.desc = content;

problem.templates = JSON.parse(q.codeDefinition);
problem.testcase = q.sampleTestCase;
Expand Down