2024-08-25 17:43:55 +02:00
|
|
|
// Code generated by sqlc. DO NOT EDIT.
|
|
|
|
// versions:
|
2024-08-29 12:21:38 +02:00
|
|
|
// sqlc v1.25.0
|
2024-08-25 17:43:55 +02:00
|
|
|
// source: app_flags.sql
|
|
|
|
|
|
|
|
package queries
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"database/sql"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/lib/pq"
|
|
|
|
)
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
const appFlagsCreateGame = `-- name: AppFlagsCreateGame :one
|
|
|
|
INSERT INTO app_flags_games (uid, tags, question_amount, seconds)
|
|
|
|
VALUES ($1, $2, $3, $4)
|
2024-08-26 00:18:45 +02:00
|
|
|
RETURNING game_id, game_seed
|
2024-08-25 17:43:55 +02:00
|
|
|
`
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
type AppFlagsCreateGameParams struct {
|
2024-08-25 17:43:55 +02:00
|
|
|
Uid sql.NullString
|
|
|
|
Tags []string
|
|
|
|
QuestionAmount int32
|
2024-08-26 20:28:20 +02:00
|
|
|
Seconds int32
|
2024-08-25 17:43:55 +02:00
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
type AppFlagsCreateGameRow struct {
|
2024-08-26 00:18:45 +02:00
|
|
|
GameID uuid.UUID
|
2024-08-26 20:28:20 +02:00
|
|
|
GameSeed uuid.UUID
|
2024-08-26 00:18:45 +02:00
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
func (q *Queries) AppFlagsCreateGame(ctx context.Context, arg AppFlagsCreateGameParams) (AppFlagsCreateGameRow, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, appFlagsCreateGame,
|
|
|
|
arg.Uid,
|
|
|
|
pq.Array(arg.Tags),
|
|
|
|
arg.QuestionAmount,
|
|
|
|
arg.Seconds,
|
|
|
|
)
|
|
|
|
var i AppFlagsCreateGameRow
|
2024-08-26 00:18:45 +02:00
|
|
|
err := row.Scan(&i.GameID, &i.GameSeed)
|
|
|
|
return i, err
|
2024-08-25 17:43:55 +02:00
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
const appFlagsCreateGameWithSeed = `-- name: AppFlagsCreateGameWithSeed :one
|
|
|
|
INSERT INTO app_flags_games (uid, tags, question_amount, seconds, game_seed)
|
|
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
|
|
RETURNING game_id
|
2024-08-25 17:43:55 +02:00
|
|
|
`
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
type AppFlagsCreateGameWithSeedParams struct {
|
|
|
|
Uid sql.NullString
|
|
|
|
Tags []string
|
|
|
|
QuestionAmount int32
|
|
|
|
Seconds int32
|
|
|
|
GameSeed uuid.UUID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) AppFlagsCreateGameWithSeed(ctx context.Context, arg AppFlagsCreateGameWithSeedParams) (uuid.UUID, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, appFlagsCreateGameWithSeed,
|
|
|
|
arg.Uid,
|
|
|
|
pq.Array(arg.Tags),
|
|
|
|
arg.QuestionAmount,
|
|
|
|
arg.Seconds,
|
|
|
|
arg.GameSeed,
|
|
|
|
)
|
|
|
|
var game_id uuid.UUID
|
|
|
|
err := row.Scan(&game_id)
|
|
|
|
return game_id, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const appFlagsGetGame = `-- name: AppFlagsGetGame :one
|
|
|
|
SELECT game_id, game_seed, uid, tags, seconds, question_amount, question_current, questions_errors, created_at, last_activity FROM app_flags_games WHERE game_id = $1 LIMIT 1
|
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) AppFlagsGetGame(ctx context.Context, gameID uuid.UUID) (AppFlagsGame, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, appFlagsGetGame, gameID)
|
2024-08-25 17:43:55 +02:00
|
|
|
var i AppFlagsGame
|
|
|
|
err := row.Scan(
|
|
|
|
&i.GameID,
|
|
|
|
&i.GameSeed,
|
|
|
|
&i.Uid,
|
|
|
|
pq.Array(&i.Tags),
|
2024-08-26 20:28:20 +02:00
|
|
|
&i.Seconds,
|
2024-08-25 17:43:55 +02:00
|
|
|
&i.QuestionAmount,
|
|
|
|
&i.QuestionCurrent,
|
2024-08-26 16:46:28 +02:00
|
|
|
&i.QuestionsErrors,
|
2024-08-25 17:43:55 +02:00
|
|
|
&i.CreatedAt,
|
|
|
|
&i.LastActivity,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
const appFlagsGetSharedData = `-- name: AppFlagsGetSharedData :one
|
2024-08-29 12:21:38 +02:00
|
|
|
SELECT id, uid, share_key, game_seed, questions, tags, seconds, created_at FROM app_flags_games_shared_data WHERE share_key = $1 LIMIT 1
|
2024-08-26 20:28:20 +02:00
|
|
|
`
|
|
|
|
|
|
|
|
func (q *Queries) AppFlagsGetSharedData(ctx context.Context, shareKey string) (AppFlagsGamesSharedDatum, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, appFlagsGetSharedData, shareKey)
|
|
|
|
var i AppFlagsGamesSharedDatum
|
|
|
|
err := row.Scan(
|
|
|
|
&i.ID,
|
2024-08-29 12:21:38 +02:00
|
|
|
&i.Uid,
|
2024-08-26 20:28:20 +02:00
|
|
|
&i.ShareKey,
|
|
|
|
&i.GameSeed,
|
|
|
|
&i.Questions,
|
|
|
|
pq.Array(&i.Tags),
|
|
|
|
&i.Seconds,
|
|
|
|
&i.CreatedAt,
|
|
|
|
)
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const appFlagsNewSharedData = `-- name: AppFlagsNewSharedData :one
|
2024-08-29 12:21:38 +02:00
|
|
|
INSERT INTO app_flags_games_shared_data (uid, share_key, game_seed, tags, questions, seconds) VALUES ($1, $2, $3, $4, $5, $6) RETURNING game_seed
|
2024-08-26 20:28:20 +02:00
|
|
|
`
|
|
|
|
|
|
|
|
type AppFlagsNewSharedDataParams struct {
|
2024-08-29 12:21:38 +02:00
|
|
|
Uid string
|
2024-08-26 20:28:20 +02:00
|
|
|
ShareKey string
|
|
|
|
GameSeed uuid.UUID
|
|
|
|
Tags []string
|
|
|
|
Questions int32
|
|
|
|
Seconds int32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *Queries) AppFlagsNewSharedData(ctx context.Context, arg AppFlagsNewSharedDataParams) (uuid.UUID, error) {
|
|
|
|
row := q.db.QueryRowContext(ctx, appFlagsNewSharedData,
|
2024-08-29 12:21:38 +02:00
|
|
|
arg.Uid,
|
2024-08-26 20:28:20 +02:00
|
|
|
arg.ShareKey,
|
|
|
|
arg.GameSeed,
|
|
|
|
pq.Array(arg.Tags),
|
|
|
|
arg.Questions,
|
|
|
|
arg.Seconds,
|
|
|
|
)
|
|
|
|
var game_seed uuid.UUID
|
|
|
|
err := row.Scan(&game_seed)
|
|
|
|
return game_seed, err
|
|
|
|
}
|
|
|
|
|
|
|
|
const appFlagsUpdateGame = `-- name: AppFlagsUpdateGame :exec
|
2024-08-25 22:14:13 +02:00
|
|
|
UPDATE app_flags_games
|
|
|
|
SET question_current = $1, last_activity = CURRENT_TIMESTAMP
|
|
|
|
WHERE game_id = $2
|
2024-08-25 17:43:55 +02:00
|
|
|
`
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
type AppFlagsUpdateGameParams struct {
|
2024-08-25 22:14:13 +02:00
|
|
|
QuestionCurrent int32
|
|
|
|
GameID uuid.UUID
|
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
func (q *Queries) AppFlagsUpdateGame(ctx context.Context, arg AppFlagsUpdateGameParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, appFlagsUpdateGame, arg.QuestionCurrent, arg.GameID)
|
2024-08-25 22:14:13 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
const appFlagsUpdateQuestionCorrect = `-- name: AppFlagsUpdateQuestionCorrect :exec
|
2024-08-25 22:14:13 +02:00
|
|
|
UPDATE app_flags_games
|
2024-08-26 16:46:28 +02:00
|
|
|
SET questions_errors = (
|
|
|
|
SELECT COALESCE(SUM(errors), 0)
|
2024-08-25 22:14:13 +02:00
|
|
|
FROM app_flags_games_answers
|
2024-08-26 16:46:28 +02:00
|
|
|
WHERE app_flags_games_answers.game_id = app_flags_games.game_id
|
2024-08-26 20:28:20 +02:00
|
|
|
), last_activity = CURRENT_TIMESTAMP
|
2024-08-26 16:46:28 +02:00
|
|
|
WHERE app_flags_games.game_id = $1
|
2024-08-25 22:14:13 +02:00
|
|
|
`
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
func (q *Queries) AppFlagsUpdateQuestionCorrect(ctx context.Context, gameID uuid.UUID) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, appFlagsUpdateQuestionCorrect, gameID)
|
2024-08-26 16:46:28 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
const appFlagsUpsertGameAnswer = `-- name: AppFlagsUpsertGameAnswer :exec
|
2024-08-26 16:46:28 +02:00
|
|
|
INSERT INTO app_flags_games_answers (game_id, question, errors)
|
|
|
|
VALUES ($1, $2, $3)
|
|
|
|
ON CONFLICT (game_id, question)
|
|
|
|
DO UPDATE SET errors = app_flags_games_answers.errors + EXCLUDED.errors
|
|
|
|
`
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
type AppFlagsUpsertGameAnswerParams struct {
|
2024-08-26 16:46:28 +02:00
|
|
|
GameID uuid.UUID
|
|
|
|
Question int32
|
|
|
|
Errors int32
|
|
|
|
}
|
|
|
|
|
2024-08-26 20:28:20 +02:00
|
|
|
func (q *Queries) AppFlagsUpsertGameAnswer(ctx context.Context, arg AppFlagsUpsertGameAnswerParams) error {
|
|
|
|
_, err := q.db.ExecContext(ctx, appFlagsUpsertGameAnswer, arg.GameID, arg.Question, arg.Errors)
|
2024-08-25 17:43:55 +02:00
|
|
|
return err
|
|
|
|
}
|