Skip to content

Commit

Permalink
fix: correct the URL and rename the var
Browse files Browse the repository at this point in the history
  • Loading branch information
K0nnyaku committed Dec 3, 2024
1 parent 53d471e commit 619e52e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/models/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Submission {
pub status: Status,
pub results: Vec<JudgeResult>,
pub creator: Thing,
pub contest_id: Option<Thing>,
pub contest: Option<Thing>,

pub created_at: chrono::NaiveDateTime,
pub updated_at: chrono::NaiveDateTime,
Expand Down
6 changes: 3 additions & 3 deletions src/routes/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub async fn get(
}))
}

#[post("/list/<id>", data = "<_auth>")]
#[post("/list/user/<id>", data = "<_auth>")]
pub async fn list_by_user(
db: &State<Surreal<Client>>,
id: &str,
Expand All @@ -91,7 +91,7 @@ pub async fn list_by_user(
}))
}

#[post("/list/<id>", data = "<_auth>")]
#[post("/list/contest/<id>", data = "<_auth>")]
pub async fn list_by_contest(
db: &State<Surreal<Client>>,
id: &str,
Expand All @@ -108,7 +108,7 @@ pub async fn list_by_contest(
}))
}

#[post("/list/<contest_id>/<user_id>", data = "<_auth>")]
#[post("/list/contest/<contest_id>/<user_id>", data = "<_auth>")]
pub async fn list_within_contest(
db: &State<Surreal<Client>>,
contest_id: &str,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub async fn create(
problem_id: &str,
code: String,
lang: Language,
contest_id: Option<&str>,
contest: Option<&str>,
) -> Result<Option<Submission>> {
Ok(db
.create("submission")
Expand All @@ -23,8 +23,8 @@ pub async fn create(
creator: ("account", account_id).into(),
results: vec![],

contest_id: (if let Some(contest_id) = contest_id {
Some(("contest", contest_id).into())
contest: (if let Some(contest) = contest {
Some(("contest", contest).into())
} else {
None
}),
Expand Down

0 comments on commit 619e52e

Please sign in to comment.