Skip to content

Commit 9903a60

Browse files
authored
fix: Problems' description (pick, edit) (clearloop#163)
* 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 * fix: comment problem desc Changed desc comment to render Question.content instead of Question.t_content, which was empty.
1 parent d1fd7fc commit 9903a60

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
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/models.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl Question {
151151
}
152152

153153
pub fn desc_comment(&self, conf: &Config) -> String {
154-
let desc = self.t_content.render();
154+
let desc = self.content.render();
155155

156156
let mut res = desc.lines().fold("\n".to_string(), |acc, e| {
157157
acc + "" + conf.code.comment_leading.as_str() + " " + e + "\n"

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy