This commit is contained in:
2026-10-03 12:48:31 +07:00
parent 7a972ea960
commit dd55079e06
8 changed files with 16 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
package repos package repos
// Application describes evidence attached to a team.
type Application struct { type Application struct {
Name string Name string
Image string Image string
+1
View File
@@ -4,6 +4,7 @@ import (
"time" "time"
) )
// Game describes a game and its scenario and teams.
type Game struct { type Game struct {
Format string Format string
ID int ID int
+1
View File
@@ -26,6 +26,7 @@ type Repo struct {
pool *pgxpool.Pool pool *pgxpool.Pool
} }
// NewGameMapRepo creates a game map repository.
func NewGameMapRepo(pool *pgxpool.Pool) *Repo { func NewGameMapRepo(pool *pgxpool.Pool) *Repo {
return &Repo{pool: pool} return &Repo{pool: pool}
} }
+3
View File
@@ -7,14 +7,17 @@ import (
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
) )
// Repo checks database health.
type Repo struct { type Repo struct {
pool *pgxpool.Pool pool *pgxpool.Pool
} }
// New creates a database health repository.
func New(pool *pgxpool.Pool) *Repo { func New(pool *pgxpool.Pool) *Repo {
return &Repo{pool: pool} return &Repo{pool: pool}
} }
// Check verifies that the database is reachable.
func (r *Repo) Check(ctx context.Context) error { func (r *Repo) Check(ctx context.Context) error {
return r.pool.Ping(ctx) return r.pool.Ping(ctx)
} }
@@ -8,16 +8,19 @@ import (
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
) )
// RefreshTokensRepo persists refresh tokens.
type RefreshTokensRepo struct { type RefreshTokensRepo struct {
pool *pgxpool.Pool pool *pgxpool.Pool
} }
// NewRefreshTokensRepo creates a refresh token repository.
func NewRefreshTokensRepo(pool *pgxpool.Pool) *RefreshTokensRepo { func NewRefreshTokensRepo(pool *pgxpool.Pool) *RefreshTokensRepo {
return &RefreshTokensRepo{ return &RefreshTokensRepo{
pool: pool, pool: pool,
} }
} }
// AddRefreshToken stores a refresh token.
func (s *RefreshTokensRepo) AddRefreshToken( func (s *RefreshTokensRepo) AddRefreshToken(
ctx context.Context, ctx context.Context,
userID int, userID int,
@@ -35,6 +38,7 @@ func (s *RefreshTokensRepo) AddRefreshToken(
return err return err
} }
// ExistsRefreshToken reports whether an unexpired refresh token exists.
func (s *RefreshTokensRepo) ExistsRefreshToken( func (s *RefreshTokensRepo) ExistsRefreshToken(
ctx context.Context, ctx context.Context,
userID int, userID int,
@@ -63,6 +67,7 @@ func (s *RefreshTokensRepo) ExistsRefreshToken(
return exists, nil return exists, nil
} }
// DeleteRefreshTokenByJti removes a refresh token by its JTI.
func (s *RefreshTokensRepo) DeleteRefreshTokenByJti( func (s *RefreshTokensRepo) DeleteRefreshTokenByJti(
ctx context.Context, ctx context.Context,
jti string, jti string,
+1
View File
@@ -1,5 +1,6 @@
package repos package repos
// Team describes a game team and its participation state.
type Team struct { type Team struct {
ParticipationStatus string ParticipationStatus string
ParticipationSource string ParticipationSource string
+3
View File
@@ -8,10 +8,12 @@ import (
"github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/pgxpool"
) )
// TeamAnswersRepo persists team answers.
type TeamAnswersRepo struct { type TeamAnswersRepo struct {
pool *pgxpool.Pool pool *pgxpool.Pool
} }
// NewTeamAnswersRepo creates a team answers repository.
func NewTeamAnswersRepo(pool *pgxpool.Pool) *TeamAnswersRepo { func NewTeamAnswersRepo(pool *pgxpool.Pool) *TeamAnswersRepo {
return &TeamAnswersRepo{ return &TeamAnswersRepo{
pool: pool, pool: pool,
@@ -45,6 +47,7 @@ func (r *TeamAnswersRepo) UpsertAnswers(
return nil return nil
} }
// GetAnswersByTeamID returns answers submitted by a team.
func (r *TeamAnswersRepo) GetAnswersByTeamID( func (r *TeamAnswersRepo) GetAnswersByTeamID(
ctx context.Context, ctx context.Context,
teamID int, teamID int,
+1
View File
@@ -2,6 +2,7 @@ package repos
import "time" import "time"
// User describes an application user.
type User struct { type User struct {
ID int ID int
Username string Username string