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;