Skip to content

Commit c376f71

Browse files
committed
Filter out hidden problems.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent 27037b8 commit c376f71

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

lib/leetcode_client.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,22 @@ leetcodeClient.getProblems = function(cb) {
8484
if (json.user_name.length === 0)
8585
return cb('session expired, please login again');
8686

87-
var problems = json.stat_status_pairs.map(function(p) {
88-
return {
89-
state: p.status || 'None',
90-
id: p.stat.question_id,
91-
name: p.stat.question__title,
92-
key: p.stat.question__title_slug,
93-
link: config.PROBLEM_URL.replace('$id', p.stat.question__title_slug),
94-
locked: p.paid_only,
95-
percent: p.stat.total_acs * 100 / p.stat.total_submitted,
96-
level: h.levelToName(p.difficulty.level)
97-
};
98-
});
87+
var problems = json.stat_status_pairs
88+
.filter(function(p) {
89+
return !p.stat.question__hide;
90+
})
91+
.map(function(p) {
92+
return {
93+
state: p.status || 'None',
94+
id: p.stat.question_id,
95+
name: p.stat.question__title,
96+
key: p.stat.question__title_slug,
97+
link: config.PROBLEM_URL.replace('$id', p.stat.question__title_slug),
98+
locked: p.paid_only,
99+
percent: p.stat.total_acs * 100 / p.stat.total_submitted,
100+
level: h.levelToName(p.difficulty.level)
101+
};
102+
});
99103

100104
return cb(null, problems);
101105
});

test/test_leetcode_client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('leetcode_client', function() {
1313

1414
client.getProblems(function(e, problems) {
1515
assert.equal(e, null);
16-
assert.equal(problems.length, 382);
16+
assert.equal(problems.length, 377);
1717
done();
1818
});
1919
});

0 commit comments

Comments
 (0)