diff options
Diffstat (limited to 'backend/db/query.sql.go')
| -rw-r--r-- | backend/db/query.sql.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/backend/db/query.sql.go b/backend/db/query.sql.go index abf2631..da13f33 100644 --- a/backend/db/query.sql.go +++ b/backend/db/query.sql.go @@ -343,6 +343,7 @@ JOIN users ON game_states.user_id = users.user_id JOIN submissions ON game_states.best_score_submission_id = submissions.submission_id WHERE game_states.game_id = $1 ORDER BY submissions.code_size ASC, submissions.created_at ASC +LIMIT 30 ` type GetRankingRow struct { @@ -716,6 +717,30 @@ func (q *Queries) UpdateCode(ctx context.Context, arg UpdateCodeParams) error { return err } +const updateCodeAndStatus = `-- name: UpdateCodeAndStatus :exec +INSERT INTO game_states (game_id, user_id, code, status) +VALUES ($1, $2, $3, $4) +ON CONFLICT (game_id, user_id) +DO UPDATE SET code = EXCLUDED.code, status = EXCLUDED.status +` + +type UpdateCodeAndStatusParams struct { + GameID int32 + UserID int32 + Code string + Status string +} + +func (q *Queries) UpdateCodeAndStatus(ctx context.Context, arg UpdateCodeAndStatusParams) error { + _, err := q.db.Exec(ctx, updateCodeAndStatus, + arg.GameID, + arg.UserID, + arg.Code, + arg.Status, + ) + return err +} + const updateGame = `-- name: UpdateGame :exec UPDATE games SET |
