database

package
v0.0.0-...-19f3900 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(srcLog *slog.Logger, o Options) logger.Interface

Types

type Contest

type Contest struct {
	Info         scheduler.ContestInfo   `gorm:"embedded"`
	Data         scheduler.ContestData   `gorm:"embedded"`
	RunningJobs  []scheduler.RunningJob  `gorm:"foreignKey:ContestID"`
	FinishedJobs []scheduler.FinishedJob `gorm:"foreignKey:ContestID"`
	Match        *Match                  `gorm:"foreignKey:ID;references:ContestID"`
}

type DB

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

func New

func New(log *slog.Logger, o Options) (*DB, error)

func (*DB) Close

func (d *DB) Close()

func (*DB) CreateContest

func (d *DB) CreateContest(ctx context.Context, info scheduler.ContestInfo, data scheduler.ContestData) error
func (d *DB) CreateInviteLink(ctx context.Context, link userauth.InviteLink) error

func (*DB) CreateRoom

func (d *DB) CreateRoom(ctx context.Context, info roomkeeper.RoomInfo) error

func (*DB) CreateRoomToken

func (d *DB) CreateRoomToken(ctx context.Context, token userauth.RoomToken) error

func (*DB) CreateRunningJob

func (d *DB) CreateRunningJob(ctx context.Context, job *scheduler.RunningJob) error

func (*DB) CreateUser

func (d *DB) CreateUser(ctx context.Context, user userauth.User, link userauth.InviteLink) error
func (d *DB) DeleteInviteLink(ctx context.Context, linkHash string, userID string) error

func (*DB) DeleteRoomToken

func (d *DB) DeleteRoomToken(ctx context.Context, tokenHash string, userID string) error

func (*DB) FinishRunningJob

func (d *DB) FinishRunningJob(ctx context.Context, data *scheduler.ContestData, job *scheduler.FinishedJob) error

func (*DB) GetContest

func (d *DB) GetContest(ctx context.Context, contestID string) (scheduler.ContestInfo, scheduler.ContestData, error)
func (d *DB) GetInviteLink(ctx context.Context, linkHash string, now timeutil.UTCTime) (userauth.InviteLink, error)

func (*DB) GetRoomToken

func (d *DB) GetRoomToken(ctx context.Context, hash string) (userauth.RoomToken, error)

func (*DB) GetUser

func (d *DB) GetUser(ctx context.Context, userID string, o ...userauth.GetUserOptions) (userauth.User, error)

func (*DB) GetUserByUsername

func (d *DB) GetUserByUsername(ctx context.Context, username string, o ...userauth.GetUserOptions) (userauth.User, error)

func (*DB) HasOwnerUser

func (d *DB) HasOwnerUser(ctx context.Context) (bool, error)

func (*DB) ListActiveRooms

func (d *DB) ListActiveRooms(ctx context.Context) ([]roomkeeper.RoomFullData, error)

func (*DB) ListContestSucceededJobs

func (d *DB) ListContestSucceededJobs(ctx context.Context, contestID string) ([]scheduler.FinishedJob, error)

func (*DB) ListContests

func (d *DB) ListContests(ctx context.Context) ([]scheduler.ContestFullData, error)

func (*DB) ListRunningContestsFull

func (d *DB) ListRunningContestsFull(ctx context.Context) ([]scheduler.ContestFullData, error)

func (*DB) ListRunningJobs

func (d *DB) ListRunningJobs(ctx context.Context) ([]scheduler.RunningJob, error)

func (*DB) ListUsers

func (d *DB) ListUsers(ctx context.Context) ([]userauth.User, error)

func (*DB) NewSessionStore

func (d *DB) NewSessionStore(ctx context.Context, opts webui.SessionOptions) sessions.Store
func (d *DB) PruneInviteLinks(ctx context.Context, now timeutil.UTCTime) error

func (*DB) StopRoom

func (d *DB) StopRoom(ctx context.Context, roomID string) error

func (*DB) UpdateContest

func (d *DB) UpdateContest(ctx context.Context, contestID string, data scheduler.ContestData) error

func (*DB) UpdateRoom

func (d *DB) UpdateRoom(ctx context.Context, roomID string, jobID maybe.Maybe[string]) error

func (*DB) UpdateUser

func (d *DB) UpdateUser(ctx context.Context, user userauth.User, srcO ...userauth.UpdateUserOptions) error

type FinishedJobData

type FinishedJobData struct {
	Status roomkeeper.JobStatus `gorm:"embedded;embeddedPrefix:status_"`
	PGN    *string
}

type Match

type Match struct {
	ContestID string                  `gorm:"primaryKey"`
	Settings  scheduler.MatchSettings `gorm:"embedded"`
	Data      scheduler.MatchData     `gorm:"embedded"`
}

type Options

type Options struct {
	Path          string        `toml:"path"`
	Debug         bool          `toml:"debug"`
	SlowThreshold time.Duration `toml:"slow-threshold"`
	BusyTimeout   time.Duration `toml:"busy-timeout"`
	NoUseWAL      bool          `toml:"no-use-wal"`
}

func (*Options) FillDefaults

func (o *Options) FillDefaults()

type Room

type Room struct {
	Info  roomkeeper.RoomInfo `gorm:"embedded"`
	JobID *string
	Job   *scheduler.RunningJob `gorm:"foreignKey:JobID"`
}

Jump to

Keyboard shortcuts

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