db

package
v0.0.0-...-e4eaca7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2025 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Challenge

type Challenge struct {
	ID       int32  `json:"id"`
	Title    string `json:"title"`
	Category string `json:"category"`
	Author   string `json:"author"`
	Text     string `json:"text"`
	TextHash string `json:"text_hash"`
}

type CreateUserParams

type CreateUserParams struct {
	Username     string `json:"username"`
	Email        string `json:"email"`
	PasswordHash string `json:"password_hash"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetMultiStatsByUserIDAndChallengeIDParams

type GetMultiStatsByUserIDAndChallengeIDParams struct {
	UserID      int32 `json:"user_id"`
	ChallengeID int32 `json:"challenge_id"`
}

type GetSingleStatsByUserIDAndChallengeIDParams

type GetSingleStatsByUserIDAndChallengeIDParams struct {
	UserID      int32 `json:"user_id"`
	ChallengeID int32 `json:"challenge_id"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type MultiChallengeStat

type MultiChallengeStat struct {
	SessionID   string           `json:"session_id"`
	UserID      int32            `json:"user_id"`
	ChallengeID int32            `json:"challenge_id"`
	CreatedAt   pgtype.Timestamp `json:"created_at"`
	TimeTaken   int32            `json:"time_taken"`
	Wpm         int32            `json:"wpm"`
	Accuracy    pgtype.Numeric   `json:"accuracy"`
	NumPlayers  int32            `json:"num_players"`
	Position    int32            `json:"position"`
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) CreateUserOverviewStats

func (q *Queries) CreateUserOverviewStats(ctx context.Context, userID int32) (UserOverviewStat, error)

func (*Queries) GetChallengeByID

func (q *Queries) GetChallengeByID(ctx context.Context, id int32) (Challenge, error)

func (*Queries) GetChallengesByCategory

func (q *Queries) GetChallengesByCategory(ctx context.Context, category string) ([]Challenge, error)

func (*Queries) GetMultiStatsByChallengeID

func (q *Queries) GetMultiStatsByChallengeID(ctx context.Context, challengeID int32) ([]MultiChallengeStat, error)

func (*Queries) GetMultiStatsByUserID

func (q *Queries) GetMultiStatsByUserID(ctx context.Context, userID int32) ([]MultiChallengeStat, error)

func (*Queries) GetMultiStatsByUserIDAndChallengeID

func (q *Queries) GetMultiStatsByUserIDAndChallengeID(ctx context.Context, arg GetMultiStatsByUserIDAndChallengeIDParams) (MultiChallengeStat, error)

func (*Queries) GetOverviewStatsByUserID

func (q *Queries) GetOverviewStatsByUserID(ctx context.Context, userID int32) (UserOverviewStat, error)

func (*Queries) GetSingleStatsByChallengeID

func (q *Queries) GetSingleStatsByChallengeID(ctx context.Context, challengeID int32) ([]SingleChallengeStat, error)

func (*Queries) GetSingleStatsByUserID

func (q *Queries) GetSingleStatsByUserID(ctx context.Context, userID int32) ([]SingleChallengeStat, error)

func (*Queries) GetSingleStatsByUserIDAndChallengeID

func (q *Queries) GetSingleStatsByUserIDAndChallengeID(ctx context.Context, arg GetSingleStatsByUserIDAndChallengeIDParams) (SingleChallengeStat, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int32) (User, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SingleChallengeStat

type SingleChallengeStat struct {
	UserID      int32            `json:"user_id"`
	ChallengeID int32            `json:"challenge_id"`
	CreatedAt   pgtype.Timestamp `json:"created_at"`
	TimeTaken   int32            `json:"time_taken"`
	Wpm         int32            `json:"wpm"`
	Accuracy    pgtype.Numeric   `json:"accuracy"`
}

type User

type User struct {
	ID           int32            `json:"id"`
	Username     string           `json:"username"`
	Email        string           `json:"email"`
	PasswordHash string           `json:"password_hash"`
	CreatedAt    pgtype.Timestamp `json:"created_at"`
}

type UserOverviewStat

type UserOverviewStat struct {
	UserID           int32 `json:"user_id"`
	SingleTotalRaces int32 `json:"single_total_races"`
	SingleTotalTime  int32 `json:"single_total_time"`
	SingleAvgWpm     int32 `json:"single_avg_wpm"`
	MultiTotalRaces  int32 `json:"multi_total_races"`
	MultiTotalTime   int32 `json:"multi_total_time"`
	MultiAvgWpm      int32 `json:"multi_avg_wpm"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL