Skip to content

Commit c574b87

Browse files
committed
fix: daily problem parsing
Changed a key to fix parsing daily problem request. Fixed when id for daily problem should be fetched. Before, it will always be fetched for the `pick` option regardless of the existence of the `-d` option
1 parent d1fd7fc commit c574b87

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cache/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn tags(v: Value) -> Option<Vec<String>> {
9898
pub fn daily(v: Value) -> Option<i32> {
9999
trace!("Parse daily...");
100100
let v_obj = v.as_object()?.get("data")?.as_object()?;
101-
match v_obj.get("dailyQuestionRecord") {
101+
match v_obj.get("activeDailyCodingChallengeQuestion") {
102102
// Handle on leetcode-com
103103
Some(v) => v,
104104
// Handle on leetcode-cn

src/cmds/pick.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ impl Command for PickCommand {
130130
crate::helper::filter(&mut problems, query.to_string());
131131
}
132132

133-
let daily_id = if m.contains_id("daily") {
133+
let daily = match m.get_one::<bool>("daily") {
134+
Some(x) => x,
135+
None => &false,
136+
};
137+
138+
let daily_id = if *daily {
134139
Some(cache.get_daily_problem_id().await?)
135140
} else {
136141
None

0 commit comments

Comments
 (0)