Skip to content
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

Show command update #9

Merged
merged 3 commits into from
Apr 21, 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
3 changes: 2 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 6 additions & 8 deletions lib/plugins/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<pre> always exists for presenting testcase)
if (!_problem.desc.includes("<pre>")) {
if (!_problem.desc.includes('<pre>')) {
// do not hit problem without html tags in desc (<pre> 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);
Expand Down
14 changes: 1 addition & 13 deletions templates/detailed.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}