diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-20 20:09:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-20 20:09:05 +0900 |
| commit | 4b5c0f0d1f9711b27ededbcdda785753325f04ea (patch) | |
| tree | b8d5e2006035af2481a9c9cd7e8300e2cd6e3cb8 /backend/query.sql | |
| parent | 1a08d06be929900fb8d8b61a1ac0611005c277e8 (diff) | |
| download | phperkaigi-2025-albatross-4b5c0f0d1f9711b27ededbcdda785753325f04ea.tar.gz phperkaigi-2025-albatross-4b5c0f0d1f9711b27ededbcdda785753325f04ea.tar.zst phperkaigi-2025-albatross-4b5c0f0d1f9711b27ededbcdda785753325f04ea.zip | |
feat(backend): add /admin/online-qualifying-ranking
Diffstat (limited to 'backend/query.sql')
| -rw-r--r-- | backend/query.sql | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/backend/query.sql b/backend/query.sql index 2a95a23..4707eff 100644 --- a/backend/query.sql +++ b/backend/query.sql @@ -132,6 +132,22 @@ JOIN submissions ON game_states.best_score_submission_id = submissions.submissio WHERE game_states.game_id = $1 ORDER BY submissions.code_size ASC, submissions.created_at ASC; +-- name: GetQualifyingRanking :many +SELECT + u.username AS username, + s1.code_size AS code_size_1, + s2.code_size AS code_size_2, + (s1.code_size + s2.code_size) AS total_code_size, + s1.created_at AS submitted_at_1, + s2.created_at AS submitted_at_2 +FROM game_states gs1 +JOIN submissions s1 ON gs1.best_score_submission_id = s1.submission_id +JOIN game_states gs2 ON gs1.user_id = gs2.user_id +JOIN submissions s2 ON gs2.best_score_submission_id = s2.submission_id +JOIN users u ON gs1.user_id = u.user_id +WHERE gs1.game_id = $1 AND gs2.game_id = $2 +ORDER BY total_code_size ASC; + -- name: UpdateCode :exec INSERT INTO game_states (game_id, user_id, code, status) VALUES ($1, $2, $3, $4) |
