aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/db/query.sql.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-03-21 11:37:48 +0900
committernsfisis <nsfisis@gmail.com>2025-03-21 11:37:48 +0900
commit95903269b252729ee6573a5b607d98fa0223cd9a (patch)
treecfed9b4320cb5c0f83364fbe8e5517b59bb10d73 /backend/db/query.sql.go
parent4b58aed45bb2356786958b4ce10b62ede26dfdb3 (diff)
downloadphperkaigi-2025-albatross-95903269b252729ee6573a5b607d98fa0223cd9a.tar.gz
phperkaigi-2025-albatross-95903269b252729ee6573a5b607d98fa0223cd9a.tar.zst
phperkaigi-2025-albatross-95903269b252729ee6573a5b607d98fa0223cd9a.zip
fix(frontend): fix submission status flickering
Diffstat (limited to 'backend/db/query.sql.go')
-rw-r--r--backend/db/query.sql.go25
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