From 042e87e9cfc130d5ebaf37cf51ba34b92c0f88c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= <46275354+fu050409@users.noreply.github.com> Date: Sat, 7 Dec 2024 06:13:51 +0800 Subject: [PATCH] fix(contest): fix submission and acceptation (#58) --- .changes/contest-list-problem.md | 5 +++++ Cargo.lock | 2 +- src/routes/contest.rs | 2 -- src/utils/contest.rs | 5 ++--- 4 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .changes/contest-list-problem.md diff --git a/.changes/contest-list-problem.md b/.changes/contest-list-problem.md new file mode 100644 index 0000000..4357dcf --- /dev/null +++ b/.changes/contest-list-problem.md @@ -0,0 +1,5 @@ +--- +"algohub-server": patch:fix +--- + +Fix listing submissions and acceptations for problems in contest list. diff --git a/Cargo.lock b/Cargo.lock index 324eefd..77daefd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,7 +71,7 @@ dependencies = [ [[package]] name = "algohub-server" -version = "0.1.14" +version = "0.1.15" dependencies = [ "anyhow", "chrono", diff --git a/src/routes/contest.rs b/src/routes/contest.rs index 40554ba..e183f4f 100644 --- a/src/routes/contest.rs +++ b/src/routes/contest.rs @@ -89,8 +89,6 @@ pub async fn list_problems( let problems = contest::list_problems(db, id, auth.id).await?; - dbg!(&problems); - Ok(Json(Response { success: true, message: "Problems listed successfully".into(), diff --git a/src/utils/contest.rs b/src/utils/contest.rs index 5025cfc..54d13ca 100644 --- a/src/utils/contest.rs +++ b/src/utils/contest.rs @@ -69,12 +69,11 @@ SELECT title, record::id(id) AS id, count( AND judge_result.status.type == "accepted" ) > 0 AS solved, count( - SELECT record::id(creator) - FROM submission WHERE record::id(creator) == $account_id AND problem == $parent.id + SELECT record::id(creator) FROM submission WHERE problem == $parent.id ) AS submittedCount, count( SELECT record::id(creator) - FROM submission WHERE record::id(creator) == $account_id AND problem == $parent.id + FROM submission WHERE problem == $parent.id AND judge_result.status.type == "accepted" ) AS acceptedCount FROM type::thing("contest", $id).problems;