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

Commit 9c1d4a8

Browse files
update ac status after submit
1 parent 3b215f2 commit 9c1d4a8

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v0.2.9
2+
update ac status after submit successfully
3+
4+
## v0.2.8
5+
show last testcases
6+
17
## v0.2.7
28
fixed float bug in result
39

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cargo install leetcode-cli
2323
**Please make sure you have logined in `leetcode.com` with `chrome`**, more info plz checkout [this](#cookies)
2424

2525
```sh
26-
leetcode 0.2.8
26+
leetcode 0.2.9
2727
clearloop <udtrokia@163.com>
2828
Here's to the crazy ones 👻
2929

‎src/cache/mod.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ impl Cache {
5151
Ok(())
5252
}
5353

54+
pub fn update_after_ac(self, rid: i32) -> Result<(), Error> {
55+
let c = conn((&self.0.conf.storage.cache()?).to_owned());
56+
let target = problems.filter(id.eq(rid));
57+
diesel::update(target).set(status.eq("ac")).execute(&c)?;
58+
Ok(())
59+
}
60+
5461
/// Download leetcode problems to db
5562
pub fn download_problems(self) -> Result<Vec<Problem>, Error> {
5663
info!("Fetching leetcode problems...");

‎src/cache/models.rs‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,20 @@ impl std::fmt::Display for VerifyResult {
264264
eca,
265265
)
266266
} else if !self.submit.compare_result.is_empty() {
267+
// Submit Successfully
268+
// TODO: result shoule be all 1;
269+
// Lines below are sucks...
270+
let cache = super::Cache::new().expect("cache gen failed");
271+
cache
272+
.update_after_ac(
273+
self.submit
274+
.question_id
275+
.parse()
276+
.expect("submit succcessfully, parse question_id to i32 failed"),
277+
)
278+
.expect("update ac to cache failed");
279+
280+
// prints
267281
let (mut rp, mut mp) = (0, 0);
268282
if let Some(n) = &self.analyse.runtime_percentile {
269283
if n.is_f64() {
@@ -280,8 +294,6 @@ impl std::fmt::Display for VerifyResult {
280294
mp = n.as_i64().unwrap_or(0);
281295
}
282296
}
283-
284-
// Submit Successfully
285297
write!(
286298
f,
287299
"\n{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}.\n",
@@ -376,7 +388,7 @@ mod verify {
376388
#[derive(Debug, Default, Deserialize)]
377389
pub struct Submit {
378390
#[serde(default)]
379-
question_id: String,
391+
pubquestion_id: String,
380392
#[serde(default)]
381393
pub last_testcase: String,
382394
#[serde(default)]

‎src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//! **Please make sure you have logined in `leetcode.com` with `chrome`**, more info plz checkout [this](#cookies)
2424
//!
2525
//! ```sh
26-
//! leetcode 0.2.8
26+
//! leetcode 0.2.9
2727
//! clearloop <udtrokia@163.com>
2828
//! Here's to the crazy ones 👻
2929
//!

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /