From 626ab209bc5b1b9f3a608a1c2a536ead3cd27a7f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 2 Apr 2025 00:50:07 +0900 Subject: fix(backend): fix incorrect aggregation of testcase results --- backend/db/query.sql.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'backend/db/query.sql.go') diff --git a/backend/db/query.sql.go b/backend/db/query.sql.go index da13f33..fece99f 100644 --- a/backend/db/query.sql.go +++ b/backend/db/query.sql.go @@ -29,15 +29,17 @@ func (q *Queries) AddMainPlayer(ctx context.Context, arg AddMainPlayerParams) er const aggregateTestcaseResults = `-- name: AggregateTestcaseResults :one SELECT CASE - WHEN COUNT(CASE WHEN r.status IS NULL THEN 1 END) > 0 THEN 'running' + WHEN COUNT(*) < (SELECT COUNT(*) FROM testcases WHERE problem_id = + (SELECT problem_id FROM games WHERE game_id = + (SELECT game_id FROM submissions AS s WHERE s.submission_id = $1))) + THEN 'running' WHEN COUNT(CASE WHEN r.status = 'internal_error' THEN 1 END) > 0 THEN 'internal_error' WHEN COUNT(CASE WHEN r.status = 'timeout' THEN 1 END) > 0 THEN 'timeout' WHEN COUNT(CASE WHEN r.status = 'runtime_error' THEN 1 END) > 0 THEN 'runtime_error' WHEN COUNT(CASE WHEN r.status = 'wrong_answer' THEN 1 END) > 0 THEN 'wrong_answer' ELSE 'success' END AS status -FROM testcases -LEFT JOIN testcase_results AS r ON testcases.testcase_id = r.testcase_id +FROM testcase_results AS r WHERE r.submission_id = $1 ` -- cgit v1.2.3-70-g09d2