Skip to content

Commit 724d664

Browse files
committed
fix: error when submitting code
1 parent 9b2632f commit 724d664

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

src/cache/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ pub fn conn(p: String) -> SqliteConnection {
2222
}
2323

2424
/// Condition submit or test
25-
#[derive(Clone, Debug)]
26-
#[derive(Default)]
25+
#[derive(Clone, Debug, Default)]
2726
pub enum Run {
2827
Test,
2928
#[default]
3029
Submit,
3130
}
3231

33-
3432
/// Requests if data not download
3533
#[derive(Clone)]
3634
pub struct Cache(pub LeetCode);
@@ -284,10 +282,6 @@ impl Cache {
284282
// 2. if test cases file exist, use the file test cases(user can edit it)
285283
// 3. test cases from problem desc all test cases
286284
// 4. sample test case from the task
287-
let test_case = test_case
288-
.or(maybe_file_testcases)
289-
.or(maybe_all_testcases)
290-
.unwrap_or(d.case);
291285

292286
File::open(code_path(&p, None)?)?.read_to_string(&mut code)?;
293287

@@ -311,7 +305,7 @@ impl Cache {
311305

312306
// pass manually data
313307
json.insert("name", p.name.to_string());
314-
json.insert("data_input", test_case);
308+
// json.insert("data_input", test_case);
315309

316310
let url = match run {
317311
Run::Test => conf.sys.urls.test(&p.slug),
@@ -381,7 +375,7 @@ impl Cache {
381375
trace!("Recur verify result {:#?}", res);
382376

383377
res.name = json.get("name").ok_or(Error::NoneError)?.to_string();
384-
res.data_input = json.get("data_input").ok_or(Error::NoneError)?.to_string();
378+
// res.data_input = json.get("data_input").ok_or(Error::NoneError)?.to_string();
385379
res.result_type = run;
386380
Ok(res)
387381
}

src/cache/models.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ pub struct VerifyResult {
237237
pub state: String,
238238
#[serde(skip)]
239239
pub name: String,
240-
#[serde(skip)]
241-
pub data_input: String,
240+
// #[serde(skip)]
241+
// pub data_input: String,
242242
#[serde(skip)]
243243
pub result_type: Run,
244244
// #[serde(default)]
@@ -258,7 +258,7 @@ pub struct VerifyResult {
258258
#[serde(default, deserialize_with = "ssr")]
259259
expected_output: Vec<String>,
260260
#[serde(default, deserialize_with = "ssr")]
261-
std_output: Vec<String>,
261+
std_output_list: Vec<String>,
262262

263263
// flatten
264264
// #[serde(flatten, default)]
@@ -295,12 +295,10 @@ impl std::fmt::Display for VerifyResult {
295295
// Pass Tests
296296
write!(
297297
f,
298-
"\n{}{}{}\n{}{}{}{}{}{}\n",
298+
"\n{}{}{}\n{}{}{}{}\n",
299299
&self.status.status_msg.green().bold(),
300300
&"Runtime: ".before_spaces(7).dimmed(),
301301
&self.status.status_runtime.dimmed(),
302-
&"\nYour input:".after_spaces(4),
303-
&self.data_input.replace('\n', "↩ "),
304302
&"\nOutput:".after_spaces(8),
305303
ca,
306304
&"\nExpected:".after_spaces(6),
@@ -376,12 +374,10 @@ impl std::fmt::Display for VerifyResult {
376374
// Wrong Answer during testing
377375
write!(
378376
f,
379-
"\n{}{}{}\n{}{}{}{}{}{}\n",
377+
"\n{}{}{}\n{}{}{}{}\n",
380378
"Wrong Answer".red().bold(),
381379
" Runtime: ".dimmed(),
382380
&self.status.status_runtime.dimmed(),
383-
&"\nYour input:".after_spaces(4),
384-
&self.data_input.replace('\n', "↩ "),
385381
&"\nOutput:".after_spaces(8),
386382
ca,
387383
&"\nExpected:".after_spaces(6),
@@ -419,13 +415,7 @@ impl std::fmt::Display for VerifyResult {
419415
self.expected_output[0],
420416
)?,
421417
// Memory Exceeded
422-
12 => write!(
423-
f,
424-
"\n{}\n\n{}{}\n",
425-
&self.status.status_msg.yellow().bold(),
426-
&"Last case:".after_spaces(5).dimmed(),
427-
&self.data_input.replace('\n', "↩ "),
428-
)?,
418+
12 => write!(f, "\n{}\n\n", &self.status.status_msg.yellow().bold(),)?,
429419
// Output Timeout Exceeded
430420
//
431421
// TODO: 13 and 14 might have some different,
@@ -475,12 +465,12 @@ impl std::fmt::Display for VerifyResult {
475465
}
476466
}
477467
_ => {
478-
if !self.std_output.is_empty() {
468+
if !self.std_output_list.is_empty() {
479469
write!(
480470
f,
481471
"{}{}",
482472
&"Stdout:".after_spaces(8).purple(),
483-
&self.std_output[0].replace('\n', &"\n".after_spaces(15))
473+
&self.std_output_list[0].replace('\n', &"\n".after_spaces(15))
484474
)
485475
} else {
486476
write!(f, "")

0 commit comments

Comments
 (0)