diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-20 23:32:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-20 23:32:22 +0900 |
| commit | 8e73d12a703e90ad908962143951178c13d0d6fe (patch) | |
| tree | 8bed43aa4b115f8bc50ed258aa192a94b6d2903e /backend/db/query.sql.go | |
| parent | aa07ba2e0a40b0097a4f9aee3c06dcbd9a749105 (diff) | |
| download | phperkaigi-2026-albatross-8e73d12a703e90ad908962143951178c13d0d6fe.tar.gz phperkaigi-2026-albatross-8e73d12a703e90ad908962143951178c13d0d6fe.tar.zst phperkaigi-2026-albatross-8e73d12a703e90ad908962143951178c13d0d6fe.zip | |
feat: add user submission history page
Allow users to view their own past submissions (code, size, status,
timestamp) for each game. Adds API endpoint, backend handler, SQL query,
and frontend page with expandable code display.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'backend/db/query.sql.go')
| -rw-r--r-- | backend/db/query.sql.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/backend/db/query.sql.go b/backend/db/query.sql.go index 02f1abf..80cbc16 100644 --- a/backend/db/query.sql.go +++ b/backend/db/query.sql.go @@ -705,6 +705,45 @@ func (q *Queries) GetSubmissionsByGameID(ctx context.Context, gameID int32) ([]S return items, nil } +const getSubmissionsByGameIDAndUserID = `-- name: GetSubmissionsByGameIDAndUserID :many +SELECT submission_id, game_id, user_id, code, code_size, status, created_at FROM submissions +WHERE game_id = $1 AND user_id = $2 +ORDER BY created_at DESC +` + +type GetSubmissionsByGameIDAndUserIDParams struct { + GameID int32 + UserID int32 +} + +func (q *Queries) GetSubmissionsByGameIDAndUserID(ctx context.Context, arg GetSubmissionsByGameIDAndUserIDParams) ([]Submission, error) { + rows, err := q.db.Query(ctx, getSubmissionsByGameIDAndUserID, arg.GameID, arg.UserID) + 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 |
