aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/db/query.sql.go8
-rw-r--r--backend/query.sql8
2 files changed, 10 insertions, 6 deletions
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
`
diff --git a/backend/query.sql b/backend/query.sql
index 2d56c1c..49fe2c1 100644
--- a/backend/query.sql
+++ b/backend/query.sql
@@ -99,15 +99,17 @@ VALUES ($1, $2, $3, $4, $5);
-- 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;
-- name: GetLatestState :one