Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addlikes anddislikes property to problem description#3

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jdneo merged 4 commits intoleetcode-tools:masterfromVigilans:vigilans/likes-in-desc
Apr 13, 2019
Merged
Show file tree
Hide file tree
Changes fromall 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
10 changes: 8 additions & 2 deletionslib/commands/show.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -152,14 +152,20 @@ function showProblem(problem, argv) {
log.printf('* %s', problem.category);
log.printf('* %s (%s%%)', h.prettyLevel(problem.level), problem.percent.toFixed(2));

if (filename)
log.printf('* Source Code: %s', chalk.yellow.underline(filename));
if (problem.likes)
log.printf('* Likes: %s', problem.likes);
if (problem.dislikes)
log.printf('* Dislikes: %s', problem.dislikes);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we need to align the whitespaces here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Since the console output is only needed for data extraction, whitespace alignment is not needed...I just wrote it this way to be in consistency with the oldleetcode-cli behavior.

else
log.printf('* Dislikes: -');
if (problem.totalAC)
log.printf('* Total Accepted: %s', problem.totalAC);
if (problem.totalSubmit)
log.printf('* Total Submissions: %s', problem.totalSubmit);
if (problem.testable && problem.testcase)
log.printf('* Testcase Example: %s', chalk.yellow(util.inspect(problem.testcase)));
if (filename)
log.printf('* Source Code: %s', chalk.yellow.underline(filename));

log.info();
log.info(problem.desc);
Expand Down
13 changes: 10 additions & 3 deletionslib/plugins/cache.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,13 +28,20 @@ plugin.getProblem = function(problem, cb) {
const k = h.KEYS.problem(problem);
const _problem = cache.get(k);
if (_problem) {
// Only hit description with html tags (<pre> always exists for presenting testcase)
if (_problem.desc.includes("<pre>")) {
// do not hit problem without html tags in desc (<pre> always exists for presenting testcase)
if (!_problem.desc.includes("<pre>")) {
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)) {
log.debug('cache discarded for being too old: ' + k + '.json');
}
// cache hit
else {
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
4 changes: 4 additions & 0 deletionslib/plugins/leetcode.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,6 +134,8 @@ plugin.getProblem = function(problem, cb) {
' question(titleSlug: $titleSlug) {',
' content',
' stats',
' likes',
' dislikes',
' codeDefinition',
' sampleTestCase',
' enableRunCode',
Expand All@@ -157,6 +159,8 @@ plugin.getProblem = function(problem, cb) {

problem.totalAC = JSON.parse(q.stats).totalAccepted;
problem.totalSubmit = JSON.parse(q.stats).totalSubmission;
problem.likes = q.likes;
problem.dislikes = q.dislikes;

const content = q.translatedContent ? q.translatedContent : q.content;
// // Replace <sup/> with '^' as the power operator
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp