Skip to content

Commit 17fcf95

Browse files
committed
fix: use get_problem_id_from_name()
1 parent 319055b commit 17fcf95

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/cmds/pick.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ impl Command for PickCommand {
139139
//check for name specified
140140
true => {
141141
match m.get_one::<String>("name").map(|name| name) {
142-
Some(quesname) => match cache.get_problem_from_name(quesname) {
143-
Ok(p) => p.fid,
142+
Some(quesname) => match cache.get_problem_id_from_name(quesname) {
143+
Ok(p) => p,
144144
Err(_) => 1,
145145
},
146146
None => {
@@ -158,18 +158,11 @@ impl Command for PickCommand {
158158
// Pick random without specify id
159159
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
160160
problem.fid
161-
});
162-
163-
let id = match fid {
164-
Ok(id) => id,
165-
Err(_) => {
166-
// Pick random without specify id
167-
let problem = &problems[rand::thread_rng().gen_range(0..problems.len())];
168-
problem.fid
161+
})
169162
}
170163
};
171164

172-
let r = cache.get_question(id).await;
165+
let r = cache.get_question(fid).await;
173166

174167
match r {
175168
Ok(q) => println!("{}", q.desc()),

0 commit comments

Comments
 (0)