models

package
v0.0.0-...-c0d5e8a Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParticipationTypeModerator = iota
	ParticipationTypeContestant
)
View Source
const (
	MatchStatusPending     = 0
	MatchStatusRunning     = 1
	MatchStatusDone        = 9
	MatchStatusSystemError = -9
)
View Source
const (
	SubmissionStatusPending           = 0
	SubmissionStatusCompiling         = 1
	SubmissionStatusAccepted          = 9
	SubmissionStatusCompilationFailed = -1
	SubmissionStatusSystemError       = -9
)
View Source
const (
	UserPrivilegeNormal = iota
	UserPrivilegeOrganizer
	UserPrivilegeSuperuser
)

Variables

View Source
var ErrLua = errors.New("")

Functions

func FakeDatabase

func FakeDatabase()

func FakeMatches

func FakeMatches()

func InitializeRedis

func InitializeRedis(client *redis.Client)

func InitializeSchemata

func InitializeSchemata(dbInput *sql.DB)

func SubmissionHistory

func SubmissionHistory(uid int32, cid int32, limit, offset int) ([]map[string]interface{}, int, error)

Types

type Contest

type Contest struct {
	Id     int32
	Title  string
	Banner int32

	Owner     int32
	StartTime int64
	EndTime   int64

	Desc    string
	Details string

	IsVisible bool
	IsRegOpen bool

	Judge    int32
	Script   string
	Playback string

	Rel struct {
		Owner          User
		Participations []ContestParticipation
	}
}

func ContestReadAll

func ContestReadAll() ([]Contest, error)

func (*Contest) AllParticipations

func (c *Contest) AllParticipations() ([]ContestParticipation, error)

func (*Contest) AllParticipationsRequiresDelegate

func (c *Contest) AllParticipationsRequiresDelegate(d bool) ([]ContestParticipation, error)

func (*Contest) AllParticipationsWithDelegate

func (c *Contest) AllParticipationsWithDelegate() ([]ContestParticipation, error)

func (*Contest) AppendScriptLog

func (c *Contest) AppendScriptLog(s string) error

func (*Contest) Create

func (c *Contest) Create() error

func (*Contest) ExecuteMatchScriptFunction

func (c *Contest) ExecuteMatchScriptFunction(fnName string, args ...lua.LValue) error

func (*Contest) ExecuteMatchScriptOnManual

func (c *Contest) ExecuteMatchScriptOnManual(arg string) error

func (*Contest) ExecuteMatchScriptOnSubmission

func (c *Contest) ExecuteMatchScriptOnSubmission(from int32) error

func (*Contest) ExecuteMatchScriptOnTimer

func (c *Contest) ExecuteMatchScriptOnTimer() error

func (*Contest) HasEnded

func (c *Contest) HasEnded() bool

func (*Contest) HasStarted

func (c *Contest) HasStarted() bool

func (*Contest) IsRunning

func (c *Contest) IsRunning() bool

func (*Contest) IsVisibleTo

func (c *Contest) IsVisibleTo(u User) bool

func (*Contest) LoadBanner

func (c *Contest) LoadBanner() (File, error)

func (*Contest) LoadPlayback

func (c *Contest) LoadPlayback() error

func (*Contest) LoadRel

func (c *Contest) LoadRel() error

func (*Contest) LuaState

func (c *Contest) LuaState() *lua.LState

func (*Contest) PartParticipation

func (c *Contest) PartParticipation(limit, offset int) ([]ContestParticipation, int, error)

func (*Contest) ParticipationOf

func (c *Contest) ParticipationOf(u User) int8

func (*Contest) Read

func (c *Contest) Read() error

func (*Contest) ReadModerators

func (c *Contest) ReadModerators() []int32

func (*Contest) ReadScriptLog

func (c *Contest) ReadScriptLog() (error, string)

func (*Contest) Representation

func (c *Contest) Representation(u User) map[string]interface{}

func (*Contest) ResetLuaState

func (c *Contest) ResetLuaState()

func (*Contest) ShortRepresentation

func (c *Contest) ShortRepresentation(u User) map[string]interface{}

func (*Contest) TailLog

func (c *Contest) TailLog() string

func (*Contest) Update

func (c *Contest) Update() error

func (*Contest) UpdateBanner

func (c *Contest) UpdateBanner() error

func (*Contest) UpdateModerators

func (c *Contest) UpdateModerators(uids []int64) error

type ContestParticipation

type ContestParticipation struct {
	User        int32
	Contest     int32
	Type        int8
	Delegate    int32
	Rating      int64
	Performance string

	Rel struct {
		User    User
		Contest Contest
	}
}

func (*ContestParticipation) Create

func (p *ContestParticipation) Create() error

func (*ContestParticipation) Read

func (p *ContestParticipation) Read() error

func (*ContestParticipation) Representation

func (p *ContestParticipation) Representation() map[string]interface{}

func (*ContestParticipation) Update

func (p *ContestParticipation) Update() error

func (*ContestParticipation) UpdateStats

func (p *ContestParticipation) UpdateStats() error

type ErrLuaType

type ErrLuaType struct {
	Inner   error
	Message string
}

func (ErrLuaType) Error

func (e ErrLuaType) Error() string

func (ErrLuaType) Unwrap

func (e ErrLuaType) Unwrap() error

type File

type File struct {
	Id      int32
	Type    string
	Content []byte
}

func (*File) Create

func (f *File) Create() error

func (*File) Read

func (f *File) Read() error

func (*File) Update

func (f *File) Update() error

type Match

type Match struct {
	Id      int32
	Contest int32
	Status  int8
	Report  string

	Rel struct {
		Contest Contest
		Parties []Submission
	}
}

func ReadByContest

func ReadByContest(cid int32) ([]Match, error)

func (*Match) Create

func (m *Match) Create() error

func (*Match) ExecuteStatsUpdateScript

func (m *Match) ExecuteStatsUpdateScript() error

func (*Match) LoadParticipations

func (m *Match) LoadParticipations() ([]ContestParticipation, error)

func (*Match) LoadRel

func (m *Match) LoadRel() error

func (*Match) PartiesCount

func (m *Match) PartiesCount() (int, error)

func (*Match) Read

func (m *Match) Read() error

func (*Match) Representation

func (m *Match) Representation() map[string]interface{}

func (*Match) SendToQueue

func (m *Match) SendToQueue(judge int32) error

func (*Match) ShortRepresentation

func (m *Match) ShortRepresentation() map[string]interface{}

func (*Match) Update

func (m *Match) Update() error

type MatchParty

type MatchParty struct {
	Match      int32
	Index      int32
	Submission int32
	Log        string

	Rel struct {
		Match      Match
		Submission Submission
	}
}

func (*MatchParty) LoadLog

func (p *MatchParty) LoadLog() error

func (*MatchParty) UpdateLog

func (p *MatchParty) UpdateLog() error

type Submission

type Submission struct {
	Id        int32
	User      int32
	Contest   int32
	CreatedAt int64
	Status    int8
	Message   string
	Language  string
	Contents  string

	Rel struct {
		User    User
		Contest Contest
	}
}

func (*Submission) Create

func (s *Submission) Create() error

func (*Submission) IsVisibleTo

func (s *Submission) IsVisibleTo(u User) bool

Call after LoadRel()

func (*Submission) LoadRel

func (s *Submission) LoadRel() error

func (*Submission) Read

func (s *Submission) Read() error

func (*Submission) Representation

func (s *Submission) Representation() map[string]interface{}

func (*Submission) SendToQueue

func (s *Submission) SendToQueue() error

func (*Submission) ShortRepresentation

func (s *Submission) ShortRepresentation() map[string]interface{}

func (*Submission) Update

func (s *Submission) Update() error

type TableSchema

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

type User

type User struct {
	// Authorization
	Id       int32
	Handle   string
	Email    string
	Password string

	// Privilege
	Privilege int8

	// Miscellaneous statistics
	JoinedAt int64

	// Customized profile
	Nickname string
	Bio      string
	Avatar   int32
}

func UserSearchByHandle

func UserSearchByHandle(handle string) ([]User, error)

func (*User) AllContests

func (u *User) AllContests() ([]map[string]interface{}, error)

func (*User) Create

func (u *User) Create() error

func (*User) EmailCheck

func (u *User) EmailCheck() bool

func (*User) LoadAvatar

func (u *User) LoadAvatar() (File, error)

Returns extension, contents, error

func (*User) MatchesPagination

func (u *User) MatchesPagination(limit int, offset int) ([]map[string]interface{}, int, error)

func (*User) ReadByEmail

func (u *User) ReadByEmail() error

func (*User) ReadByHandle

func (u *User) ReadByHandle() error

func (*User) ReadById

func (u *User) ReadById() error

func (*User) Representation

func (u *User) Representation() map[string]interface{}

func (*User) ShortRepresentation

func (u *User) ShortRepresentation() map[string]interface{}

func (*User) Update

func (u *User) Update() error

func (*User) UpdateAvatar

func (u *User) UpdateAvatar() error

func (*User) UpdatePassword

func (u *User) UpdatePassword() error

func (*User) VerifyPassword

func (u *User) VerifyPassword(pw string) bool

Jump to

Keyboard shortcuts

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