diff options
Diffstat (limited to 'backend/query.sql')
| -rw-r--r-- | backend/query.sql | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/backend/query.sql b/backend/query.sql index 0d32944..e767746 100644 --- a/backend/query.sql +++ b/backend/query.sql @@ -75,3 +75,17 @@ VALUES ($1, $2, $3, $4); -- name: CreateTestcaseResult :exec INSERT INTO testcase_results (submission_id, testcase_id, status, stdout, stderr) 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(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 +WHERE r.submission_id = $1; |
