Documentation
¶
Index ¶
- Constants
- Variables
- func CanEditContest(contestID, userID uint) bool
- func DefaultString(value, def string) string
- func DeleteWhiteEmail(id uint) error
- func EqualTime(t1, t2 time.Time) bool
- func GetBcryptCost() int
- func GetWorkers() ([]*work.WorkerObservation, error)
- func InitDB()
- func InitJobs()
- func IsContestParticipant(contestID, userID uint) (bool, error)
- func IsContestWriter(contestID, userID uint) (bool, error)
- func MaxDuration(a, b time.Duration) time.Duration
- func MaxInt(a, b int) int
- func MaxLong(a, b int64) int64
- func MinInt(a, b int) int
- func NewContest(out *Contest) error
- func NewProblem(problem *Problem) error
- func ResetPassword(token, password string) error
- func StartEmailConfirmation(email *WhiteEmail) error
- func StartPasswordReset(user *User) error
- func StopPool()
- func Submit(submission *Submission) error
- type Authority
- type CaseSet
- type Contest
- func (c *Contest) AddParticipant(userID uint) error
- func (c *Contest) CanEdit(s *UserSession) bool
- func (c *Contest) CanViewProblems(s *UserSession) (bool, error)
- func (c *Contest) Ended(t time.Time, s *UserSession) (bool, error)
- func (c *Contest) FetchParticipants()
- func (c *Contest) FetchProblems()
- func (c *Contest) FetchWriters()
- func (c *Contest) GetStandings(session *UserSession) ([]Score, error)
- func (c *Contest) GetSubmissions(session *UserSession, limit, page int, userID, problemID *uint) ([]Submission, int, error)
- func (c *Contest) IsOpen(t time.Time, s *UserSession) (bool, error)
- func (c *Contest) IsParticipant(userID uint) (bool, error)
- func (c *Contest) IsWriter(userID uint) (bool, error)
- func (c *Contest) Started(t time.Time, s *UserSession) (bool, error)
- func (c *Contest) Update() error
- func (c *Contest) UpdateWriters() error
- type ContestJudgementStatus
- type ContestsParticipant
- type EmailConfirmation
- type ErrJudgeSourceCodeCompile
- type JudgeResult
- type JudgeSetResult
- type JudgeType
- type JudgementConfig
- type JudgementStatus
- type Language
- type PasswordResetToken
- type Problem
- func (p *Problem) CanEdit(s *UserSession) bool
- func (p *Problem) CanView(s *UserSession) bool
- func (p *Problem) Delete()
- func (p *Problem) DeleteSamples()
- func (p *Problem) FetchCaseSets()
- func (p *Problem) FetchContest()
- func (p *Problem) FetchJudgementConfig()
- func (p *Problem) FetchSamples()
- func (p *Problem) FetchSubmissions()
- func (p *Problem) FetchWriter()
- func (p *Problem) GetSubmissionsReversed() []Submission
- func (p *Problem) Rejudge() error
- func (p *Problem) ReplaceTestCases(archive []byte) error
- func (p *Problem) Update(request *Problem)
- func (p *Problem) UpdateSamples()
- type Sample
- type Score
- type ScoreDetail
- type Submission
- func (s *Submission) CanView(session *UserSession) bool
- func (s *Submission) Delete()
- func (s *Submission) FetchJudgeSetResults(sorted bool)
- func (s *Submission) FetchJudgeSetResultsDeeply(sorted bool)
- func (s *Submission) FetchJudgeSetResultsDeeplyForContest(session *UserSession) error
- func (s *Submission) FetchLanguage()
- func (s *Submission) FetchProblem()
- func (s *Submission) FetchUser()
- func (s *Submission) IsWrong() bool
- func (s *Submission) SetStatus(status JudgementStatus) error
- type TestCase
- type User
- func FindUserByEmail(email string) *User
- func FindUserByName(name string, email bool) *User
- func GetAllUsers(email bool) []User
- func GetUser(id uint, email bool) *User
- func NewUser(name, displayName, email, password string, token *EmailConfirmation) (*User, error)
- func UniqueUsers(users []User) []User
- type UserSession
- type WhiteEmail
Constants ¶
View Source
const (
EmailConfirmationTokenLifetime = 7 * 24 * time.Hour
)
View Source
const PasswordResetTokenLifeTime = 30 * time.Minute
View Source
const (
WhiteEmailPermanentLifeTime time.Duration = -1
)
Variables ¶
View Source
var ( ErrNilArgument = errors.New("nil argument(s)") ErrInvalidFileNameOrDirectoryStructure = errors.New("ファイルの命名かディレクトリの構造が正しくありません。") )
View Source
var ( ErrUserIDIsZero = errors.New("User IDが0です") ErrUserNameAlreadyExists = errors.New("user nameはすでに使用されています") ErrEmailAlreadyExists = errors.New("emailはすでに使用されています") )
View Source
var ( ErrLogin = errors.New("incorrect username or password") ErrSessionCreateFailed = errors.New("retry limit exceeded") )
View Source
var ErrInvalidToken = errors.New("invalid password reset token")
View Source
var ErrParseOutput = errors.New("stdout parse error")
Functions ¶
func CanEditContest ¶
func DefaultString ¶
func DeleteWhiteEmail ¶
func GetBcryptCost ¶
func GetBcryptCost() int
func GetWorkers ¶
func GetWorkers() ([]*work.WorkerObservation, error)
func IsContestParticipant ¶
func IsContestWriter ¶
func NewContest ¶
func NewProblem ¶
func ResetPassword ¶
func StartEmailConfirmation ¶
func StartEmailConfirmation(email *WhiteEmail) error
func StartPasswordReset ¶
func Submit ¶
func Submit(submission *Submission) error
Types ¶
type CaseSet ¶
type CaseSet struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `sql:"index" json:"-"`
ProblemID uint `gorm:"not null" json:"problemID"`
Point int `gorm:"not null; default:'0'" json:"point"`
TestCases []TestCase `json:"-"`
}
func GetCaseSet ¶
func (*CaseSet) DeletePermanently ¶
func (s *CaseSet) DeletePermanently()
func (*CaseSet) FetchTestCases ¶
func (s *CaseSet) FetchTestCases()
func (*CaseSet) UpdatePoint ¶
type Contest ¶
type Contest struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `sql:"index" json:"-"`
Title string `json:"title"`
Description string `gorm:"type:text" json:"description"`
StartAt time.Time `json:"startAt"`
EndAt time.Time `json:"endAt"`
Writers []User `gorm:"many2many:contests_writers;" json:"writers"`
Participants []User `gorm:"many2many:contests_participants;" json:"-"`
ContestsParticipants []ContestsParticipant `json:"participants"`
Problems []Problem `json:"problems"`
Duration *time.Duration `json:"duration"`
}
func GetAllContests ¶
func GetContest ¶
func GetContestDeeply ¶
func GetContestDeeply(id uint, session *UserSession) *Contest
func (*Contest) AddParticipant ¶
func (*Contest) CanEdit ¶
func (c *Contest) CanEdit(s *UserSession) bool
func (*Contest) CanViewProblems ¶
func (c *Contest) CanViewProblems(s *UserSession) (bool, error)
func (*Contest) FetchParticipants ¶
func (c *Contest) FetchParticipants()
func (*Contest) FetchProblems ¶
func (c *Contest) FetchProblems()
func (*Contest) FetchWriters ¶
func (c *Contest) FetchWriters()
func (*Contest) GetStandings ¶
func (c *Contest) GetStandings(session *UserSession) ([]Score, error)
func (*Contest) GetSubmissions ¶
func (c *Contest) GetSubmissions(session *UserSession, limit, page int, userID, problemID *uint) ([]Submission, int, error)
func (*Contest) UpdateWriters ¶
type ContestJudgementStatus ¶
type ContestJudgementStatus struct {
UserID uint `gorm:"primary_key" sql:"type:int unsigned" json:"userID"`
ProblemID uint `gorm:"primary_key" sql:"type:int unsigned" json:"problemID"`
ContestID uint `gorm:"not null" json:"contestID"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Status JudgementStatus `gorm:"not null; default:'0'" json:"status"`
Point int `gorm:"not null; default:'0'" json:"point"`
}
func GetContestJudgementStatuses ¶
func GetContestJudgementStatuses(contestID uint, userID uint) ([]ContestJudgementStatus, error)
type ContestsParticipant ¶
type ContestsParticipant struct {
CreatedAt time.Time `gorm:"default:'1971-01-01 00:00:00'" json:"createdAt"`
ContestID uint `gorm:"not null" json:"contestID"`
UserID uint `gorm:"not null" json:"userID"`
User User `json:"user" json:"user"`
}
func (*ContestsParticipant) FetchUser ¶
func (p *ContestsParticipant) FetchUser()
type EmailConfirmation ¶
type EmailConfirmation struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LifeTime time.Duration `json:"lifeTime"`
Token string `gorm:"not null; index" json:"-"`
WhiteEmailID uint `gorm:"not null" json:"whiteEmailID"`
WhiteEmail WhiteEmail `json:"whiteEmail"`
}
func GetEmailConfirmation ¶
func GetEmailConfirmation(token string) *EmailConfirmation
func (*EmailConfirmation) FetchWhiteEmail ¶
func (c *EmailConfirmation) FetchWhiteEmail()
type ErrJudgeSourceCodeCompile ¶
type ErrJudgeSourceCodeCompile struct {
// contains filtered or unexported fields
}
func (ErrJudgeSourceCodeCompile) Error ¶
func (e ErrJudgeSourceCodeCompile) Error() string
type JudgeResult ¶
type JudgeResult struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
JudgeSetResultID uint `gorm:"not null" json:"-"`
TestCase TestCase `json:"-"`
TestCaseID uint `gorm:"not null" json:"-"`
Status JudgementStatus `gorm:"not null; default:'0'" json:"status"`
ExecTime time.Duration `json:"execTime"`
MemoryUsage int64 `json:"memoryUsage"`
}
func (*JudgeResult) Delete ¶
func (r *JudgeResult) Delete()
func (*JudgeResult) FetchTestCase ¶
func (r *JudgeResult) FetchTestCase()
type JudgeSetResult ¶
type JudgeSetResult struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
SubmissionID uint `gorm:"not null" json:"-"`
CaseSet CaseSet `json:"caseSet"`
CaseSetID uint `gorm:"not null" json:"caseSetID"`
Point int `json:"point"`
Status JudgementStatus `gorm:"not null; default:'0'" json:"status"`
JudgeResults []JudgeResult `json:"judgeResults"`
ExecTime time.Duration `json:"execTime"`
MemoryUsage int64 `json:"memoryUsage"`
}
func (*JudgeSetResult) Delete ¶
func (r *JudgeSetResult) Delete()
func (*JudgeSetResult) FetchCaseSet ¶
func (r *JudgeSetResult) FetchCaseSet()
func (*JudgeSetResult) FetchJudgeResults ¶
func (r *JudgeSetResult) FetchJudgeResults(sorted bool)
func (*JudgeSetResult) GetJudgeResultsSorted ¶
func (r *JudgeSetResult) GetJudgeResultsSorted() []JudgeResult
type JudgementConfig ¶
type JudgementConfig struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
ProblemID *uint `json:"-"`
JudgeSourceCode *string `gorm:"type:text" json:"judgeSourceCode,omitempty"`
LanguageID *uint `json:"languageID,omitempty"`
Language *Language `json:"language,omitempty"`
Difference float64 `json:"difference"`
}
func (*JudgementConfig) FetchLanguage ¶
func (d *JudgementConfig) FetchLanguage()
type JudgementStatus ¶
type JudgementStatus int
const ( StatusInQueue JudgementStatus = 0 StatusJudging JudgementStatus = 1 StatusAccepted JudgementStatus = 2 StatusPresentationError JudgementStatus = 3 StatusWrongAnswer JudgementStatus = 4 StatusTimeLimitExceeded JudgementStatus = 5 StatusMemoryLimitExceeded JudgementStatus = 6 StatusRuntimeError JudgementStatus = 7 StatusCompileError JudgementStatus = 8 StatusOutputLimitExceeded JudgementStatus = 9 StatusUnknownError JudgementStatus = 10 )
type Language ¶
type Language struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
ImageName string `gorm:"not null" json:"-"`
DisplayName string `gorm:"not null; unique_index" json:"displayName"`
FileName string `gorm:"not null" json:"-"`
ExeFileName string `gorm:"not null" json:"-"`
CompileCommand string `gorm:"not null" json:"compileCommand"`
ExecCommand string `gorm:"not null" json:"execCommand"`
}
func GetAllLanguages ¶
func GetAllLanguages() []*Language
func GetLanguage ¶
func (Language) GetCompileCommandSlice ¶
func (Language) GetExecCommandSlice ¶
type PasswordResetToken ¶
type PasswordResetToken struct {
ID uint `gorm:"primary_key" json:"-"`
CreatedAt time.Time `json:"-"`
Token string `gorm:"index; not null"`
UserID uint `gorm:"not null"`
User User
}
func GetPasswordResetToken ¶
func GetPasswordResetToken(token string) *PasswordResetToken
func (*PasswordResetToken) FetchUser ¶
func (t *PasswordResetToken) FetchUser()
type Problem ¶
type Problem struct {
ID uint `gorm:"primary_key" json:"id"`
WriterID uint `gorm:"not null" json:"writerID"`
Writer User `gorm:"ForeignKey:WriterID" json:"writer,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Title string `gorm:"not null" json:"title"`
Body string `gorm:"type:text; not null" json:"body"`
InputFormat string `gorm:"type:text" json:"inputFormat"`
OutputFormat string `gorm:"type:text" json:"outputFormat"`
Constraints string `gorm:"type:text" json:"constraints"`
Samples []Sample `json:"samples,omitempty"`
TimeLimit time.Duration `gorm:"not null" json:"timeLimit" validate:"required,max=60000000000,min=1000000000"`
MemoryLimit int `gorm:"not null" json:"memoryLimit" validate:"required,max=512,min=128"`
JudgeType JudgeType `gorm:"not null; default:'0'" json:"judgeType" validate:"max=2,min=0"`
CaseSets []CaseSet `json:"caseSets,omitempty"`
Submissions []Submission `json:"-"`
Contest *Contest `json:"contest,omitempty"`
ContestID *uint `json:"contestID"`
JudgementConfig *JudgementConfig `json:"judgementConfig,omitempty"`
}
func GetNoContestProblems ¶
func GetNoContestProblems() []Problem
func GetProblem ¶
func (*Problem) CanEdit ¶
func (p *Problem) CanEdit(s *UserSession) bool
func (*Problem) CanView ¶
func (p *Problem) CanView(s *UserSession) bool
func (*Problem) DeleteSamples ¶
func (p *Problem) DeleteSamples()
func (*Problem) FetchCaseSets ¶
func (p *Problem) FetchCaseSets()
func (*Problem) FetchContest ¶
func (p *Problem) FetchContest()
func (*Problem) FetchJudgementConfig ¶
func (p *Problem) FetchJudgementConfig()
func (*Problem) FetchSamples ¶
func (p *Problem) FetchSamples()
func (*Problem) FetchSubmissions ¶
func (p *Problem) FetchSubmissions()
func (*Problem) FetchWriter ¶
func (p *Problem) FetchWriter()
func (*Problem) GetSubmissionsReversed ¶
func (p *Problem) GetSubmissionsReversed() []Submission
func (*Problem) ReplaceTestCases ¶
func (*Problem) UpdateSamples ¶
func (p *Problem) UpdateSamples()
type Sample ¶
type Score ¶
type Score struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Point int `json:"point"`
UserID uint `gorm:"not null" json:"userID"`
ContestID uint `gorm:"not null" json:"-"`
ScoreDetails []ScoreDetail `json:"details"`
ScoreTime time.Duration `gorm:"-" json:"scoreTime"`
}
func (*Score) FetchDetails ¶
func (s *Score) FetchDetails()
type ScoreDetail ¶
type ScoreDetail struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Point int `json:"point"`
WrongCount int `gorm:"not null" json:"wrongCount"`
Accepted bool `gorm:"not null" json:"accepted"`
ScoreID uint `gorm:"not null" json:"-"`
ProblemID uint `gorm:"not null" json:"problemID"`
ScoreTime time.Duration `gorm:"-" json:"scoreTime"`
}
type Submission ¶
type Submission struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
UserID uint `gorm:"not null" json:"userID"`
User User `json:"user"`
ProblemID uint `gorm:"not null" json:"problemID"`
Problem Problem `json:"problem"`
LanguageID uint `gorm:"not null" json:"languageID"`
Language Language `json:"language"`
SourceCode string `gorm:"type:text; not null" json:"sourceCode"`
Point int `json:"point"`
Status JudgementStatus `gorm:"default:'0'" json:"status"`
ErrorLog string `gorm:"type:text" json:"errorLog"`
ExecTime time.Duration `json:"execTime"`
MemoryUsage int64 `json:"memoryUsage"`
CodeBytes uint `json:"codeBytes"`
JudgeSetResults []JudgeSetResult `json:"judgeSetResults,omitempty"`
ContestID *uint `json:"-"`
}
func GetSubmission ¶
func GetSubmission(submissionID uint) *Submission
func (*Submission) CanView ¶
func (s *Submission) CanView(session *UserSession) bool
func (*Submission) Delete ¶
func (s *Submission) Delete()
func (*Submission) FetchJudgeSetResults ¶
func (s *Submission) FetchJudgeSetResults(sorted bool)
func (*Submission) FetchJudgeSetResultsDeeply ¶
func (s *Submission) FetchJudgeSetResultsDeeply(sorted bool)
func (*Submission) FetchJudgeSetResultsDeeplyForContest ¶
func (s *Submission) FetchJudgeSetResultsDeeplyForContest(session *UserSession) error
func (*Submission) FetchLanguage ¶
func (s *Submission) FetchLanguage()
func (*Submission) FetchProblem ¶
func (s *Submission) FetchProblem()
func (*Submission) FetchUser ¶
func (s *Submission) FetchUser()
func (*Submission) IsWrong ¶
func (s *Submission) IsWrong() bool
func (*Submission) SetStatus ¶
func (s *Submission) SetStatus(status JudgementStatus) error
type TestCase ¶
type TestCase struct {
gorm.Model
CaseSetID uint `gorm:"not null"`
Input string `gorm:"type:longtext; not null"`
Output string `gorm:"type:longtext; not null"`
}
func (TestCase) DeletePermanently ¶
func (c TestCase) DeletePermanently()
type User ¶
type User struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `sql:"index" json:"-"`
Name string `gorm:"not null;unique_index" json:"name"`
DisplayName string `gorm:"not null" json:"displayName"`
Email string `gorm:"not null;unique_index" json:"email,omitempty"`
Authority Authority `gorm:"not null" json:"authority"`
IsDeleted bool `gorm:"not null;default:'0'" json:"-"`
PasswordDigest string `gorm:"not null" json:"-"`
}
func FindUserByEmail ¶
func FindUserByName ¶
func GetAllUsers ¶
func NewUser ¶
func NewUser(name, displayName, email, password string, token *EmailConfirmation) (*User, error)
func UniqueUsers ¶
func (*User) IsCorrectPassword ¶
type UserSession ¶
type UserSession struct {
ID uint `gorm:"primary_key"`
CreatedAt time.Time
UpdatedAt time.Time
User User
UserID uint `gorm:"not null"`
TokenDigest string `gorm:"not null"`
}
func CheckLogin ¶
func CheckLogin(token string) *UserSession
func GetSession ¶
func GetSession(id uint) *UserSession
func NewSession ¶
func NewSession(email, password string) (*UserSession, string, error)
emailとpasswordが正しければ新しいUserSessionとTokenを返す
func (*UserSession) Delete ¶
func (s *UserSession) Delete()
func (*UserSession) FetchUser ¶
func (s *UserSession) FetchUser()
type WhiteEmail ¶
type WhiteEmail struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
LifeTime time.Duration `json:"lifeTime"`
Email string `gorm:"not null; unique_index" json:"email"`
CreatedByID uint `gorm:"not null" json:"createdByID"`
CreatedBy User `gorm:"ForeignKey:CreatedByID" json:"createdBy"`
}
func GetWhiteEmail ¶
func GetWhiteEmail(email string) *WhiteEmail
func GetWhiteEmails ¶
func GetWhiteEmails() []WhiteEmail
func NewWhiteEmail ¶
func NewWhiteEmail(email string, user *User) *WhiteEmail
func (*WhiteEmail) FetchCreatedBy ¶
func (e *WhiteEmail) FetchCreatedBy(email bool)
Source Files
¶
- case_set.go
- contest.go
- contest_judgement_status.go
- db.go
- email_confirmation.go
- job.go
- judge_result.go
- judge_set_result.go
- judgement_config.go
- judgement_evaluator.go
- judgement_job.go
- language.go
- password_reset.go
- precision_evaluator.go
- problem.go
- sample.go
- score.go
- score_detail.go
- simple_evaluator.go
- special_evaluator.go
- submission.go
- test_case.go
- user.go
- user_session.go
- util.go
- white_email.go
Click to show internal directories.
Click to hide internal directories.