diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-17 00:45:46 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-17 00:45:46 +0900 |
| commit | 611d93ea8a5dcc7dd92ec412e8fb28078438b31b (patch) | |
| tree | 9b08446290e60af9bcda7547ece21e8dc6c40e76 /backend/db | |
| parent | a49e0b2fc1a59b54043b9ca93828346c027973eb (diff) | |
| download | iosdc-japan-2025-albatross-611d93ea8a5dcc7dd92ec412e8fb28078438b31b.tar.gz iosdc-japan-2025-albatross-611d93ea8a5dcc7dd92ec412e8fb28078438b31b.tar.zst iosdc-japan-2025-albatross-611d93ea8a5dcc7dd92ec412e8fb28078438b31b.zip | |
feat(backend): add admin pages for submissions
Diffstat (limited to 'backend/db')
| -rw-r--r-- | backend/db/query.sql.go | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/backend/db/query.sql.go b/backend/db/query.sql.go index 05c841d..e807be4 100644 --- a/backend/db/query.sql.go +++ b/backend/db/query.sql.go @@ -500,6 +500,63 @@ func (q *Queries) GetRanking(ctx context.Context, gameID int32) ([]GetRankingRow return items, nil } +const getSubmissionByID = `-- name: GetSubmissionByID :one +SELECT submission_id, game_id, user_id, code, code_size, status, created_at +FROM submissions +WHERE submission_id = $1 +LIMIT 1 +` + +func (q *Queries) GetSubmissionByID(ctx context.Context, submissionID int32) (Submission, error) { + row := q.db.QueryRow(ctx, getSubmissionByID, submissionID) + var i Submission + err := row.Scan( + &i.SubmissionID, + &i.GameID, + &i.UserID, + &i.Code, + &i.CodeSize, + &i.Status, + &i.CreatedAt, + ) + return i, err +} + +const getSubmissionsByGameID = `-- name: GetSubmissionsByGameID :many +SELECT submission_id, game_id, user_id, code, code_size, status, created_at +FROM submissions +WHERE game_id = $1 +ORDER BY created_at DESC +` + +func (q *Queries) GetSubmissionsByGameID(ctx context.Context, gameID int32) ([]Submission, error) { + rows, err := q.db.Query(ctx, getSubmissionsByGameID, gameID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []Submission + for rows.Next() { + var i Submission + if err := rows.Scan( + &i.SubmissionID, + &i.GameID, + &i.UserID, + &i.Code, + &i.CodeSize, + &i.Status, + &i.CreatedAt, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getTestcaseByID = `-- name: GetTestcaseByID :one SELECT testcase_id, problem_id, stdin, stdout FROM testcases WHERE testcase_id = $1 @@ -518,6 +575,41 @@ func (q *Queries) GetTestcaseByID(ctx context.Context, testcaseID int32) (Testca return i, err } +const getTestcaseResultsBySubmissionID = `-- name: GetTestcaseResultsBySubmissionID :many +SELECT testcase_result_id, submission_id, testcase_id, status, stdout, stderr, created_at +FROM testcase_results +WHERE submission_id = $1 +ORDER BY created_at +` + +func (q *Queries) GetTestcaseResultsBySubmissionID(ctx context.Context, submissionID int32) ([]TestcaseResult, error) { + rows, err := q.db.Query(ctx, getTestcaseResultsBySubmissionID, submissionID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []TestcaseResult + for rows.Next() { + var i TestcaseResult + if err := rows.Scan( + &i.TestcaseResultID, + &i.SubmissionID, + &i.TestcaseID, + &i.Status, + &i.Stdout, + &i.Stderr, + &i.CreatedAt, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + const getUserAuthByUsername = `-- name: GetUserAuthByUsername :one SELECT users.user_id, username, display_name, icon_path, is_admin, label, created_at, user_auth_id, user_auths.user_id, auth_type, password_hash FROM users JOIN user_auths ON users.user_id = user_auths.user_id |
