Documentation ¶
Index ¶
- Constants
- Variables
- func Fields(s ...string) []string
- func NewRegisterService(u Users) *registerService
- type Categories
- type Category
- type CategoryFilter
- type CategoryFilterType
- type ForgottenPasswordKey
- type HashedPassword
- type Language
- type PagedSubmissionList
- type PaginationData
- type Problem
- type ProblemInfo
- type ProblemInfoQuery
- type ProblemList
- type ProblemListQuery
- type ProblemListRequest
- type ProblemQuery
- type ProblemSortField
- type ProblemStoredData
- type ProblemTag
- type ProblemUserInfo
- type Problems
- type RegisterRequest
- type RegisterService
- type SolvedStatus
- type SortDirection
- type Submission
- type SubmissionList
- type SubmissionListQuery
- type SubmissionListRequest
- type SubmissionSortField
- type Submissions
- type SubmissionsQuery
- type SubmitRequest
- type SubmitService
- type Tag
- type Tags
- type TagsService
- type User
- type UserActivationInfo
- type UserSettings
- type Users
- type Verdict
Constants ¶
View Source
const ( VerdictAC = Verdict(problems.VerdictAC) VerdictWA = Verdict(problems.VerdictWA) VerdictRE = Verdict(problems.VerdictRE) VerdictTL = Verdict(problems.VerdictTL) VerdictML = Verdict(problems.VerdictML) VerdictXX = Verdict(problems.VerdictXX) VerdictDR = Verdict(problems.VerdictDR) VerdictPC = Verdict(problems.VerdictPC) VerdictPE = Verdict(problems.VerdictPE) VerdictCE Verdict = 998 VerdictRU Verdict = 999 VerdictUP Verdict = 1000 )
Variables ¶
View Source
var ( ErrorProblemNotFound = errors.New("njudge: problem not found") ErrorFileNotFound = errors.New("njudge: file not found") ErrorStatementNotFound = errors.New("njudge: statement not found") ErrorProblemTagNotFound = errors.New("njudge: problem tag not found") )
View Source
var ( ErrorNonAlphanumeric = errors.New("njudge: string is not alphanumeric") ErrorFieldRequired = errors.New("njudge: field must not be empty") ErrorUnknownRole = errors.New("njudge: unknown role") ErrorSameName = errors.New("njudge: name already in use") ErrorSameEmail = errors.New("njudge: email already in use") )
View Source
var (
ErrorCategoryNotFound = errors.New("njudge: category not found")
)
View Source
var ErrorSubmissionNotFound = errors.New("njudge: submission not found")
View Source
var (
ErrorTagNotFound = errors.New("njudge: tag not found")
)
View Source
var (
ErrorUnableToModifyProblemTags = errors.New("njudge: user can't modify tags")
)
View Source
var ErrorUnsupportedLanguage = errors.New("njudge: unsupported language")
View Source
var (
ErrorUserNotFound = errors.New("njudge: user not found")
)
View Source
var ProblemFields = struct { ID string Problemset string Problem string Category string SolverCount string Tags string }{ ID: "id", Problemset: "problemset", Problem: "problem", Category: "category", SolverCount: "category", Tags: "tags", }
View Source
var SubmissionFields = struct { ID string UserID string ProblemID string Language string Source string Private string Started string Verdict string Ontest string Submitted string Status string Judged string Score string }{ ID: "id", UserID: "user_id", ProblemID: "problem_id", Language: "language", Source: "source", Private: "private", Started: "started", Verdict: "verdict", Ontest: "ontest", Submitted: "submitted", Status: "status", Judged: "judged", Score: "score", }
View Source
var SubmissionRejudgeFields = []string{SubmissionFields.Judged, SubmissionFields.Started}
View Source
var UserFields = struct { ID string Name string Password string Email string ActivationInfo string Role string Points string Settings string Created string ForgottenPasswordKey string }{ ID: "id", Name: "name", Password: "password", Email: "email", ActivationInfo: "activated", Role: "role", Points: "points", Settings: "settings", Created: "created", ForgottenPasswordKey: "forgotten_password_key", }
Functions ¶
func NewRegisterService ¶
func NewRegisterService(u Users) *registerService
Types ¶
type Categories ¶
type Category ¶
func NewCategory ¶
type CategoryFilter ¶
type CategoryFilter struct { Type CategoryFilterType Value interface{} }
func NewCategoryEmptyFilter ¶
func NewCategoryEmptyFilter() CategoryFilter
func NewCategoryIDFilter ¶
func NewCategoryIDFilter(ID int) CategoryFilter
type CategoryFilterType ¶
type CategoryFilterType int
const ( CategoryFilterNone CategoryFilterType = iota CategoryFilterEmpty CategoryFilterID )
type ForgottenPasswordKey ¶
func NewForgottenPasswordKey ¶
func NewForgottenPasswordKey(validDuration time.Duration) ForgottenPasswordKey
func (*ForgottenPasswordKey) IsValid ¶
func (f *ForgottenPasswordKey) IsValid() bool
type HashedPassword ¶
type HashedPassword string
func NewHashedPassword ¶
func NewHashedPassword(password string) (HashedPassword, error)
type PagedSubmissionList ¶
type PagedSubmissionList struct { PaginationData PaginationData Submissions []Submission }
type Problem ¶
type Problem struct { ID int Problemset string Problem string Category *Category SolverCount int Tags []ProblemTag }
func NewProblem ¶
func (*Problem) SetCategory ¶
func (*Problem) WithStoredData ¶
func (p *Problem) WithStoredData(store problems.Store) (ProblemStoredData, error)
type ProblemInfo ¶
type ProblemInfo struct {
UserInfo *ProblemUserInfo
}
type ProblemInfoQuery ¶
type ProblemInfoQuery interface {
GetProblemData(ctx context.Context, problemID, userID int) (*ProblemInfo, error)
}
type ProblemList ¶
type ProblemList struct { PaginationData PaginationData Problems []Problem }
type ProblemListQuery ¶
type ProblemListQuery interface {
GetProblemList(ctx context.Context, req ProblemListRequest) (*ProblemList, error)
}
type ProblemListRequest ¶
type ProblemListRequest struct { Problemset string SortDir SortDirection SortField ProblemSortField Page int PerPage int TitleFilter string TagFilter []string CategoryFilter CategoryFilter }
func (ProblemListRequest) IsFiltered ¶
func (r ProblemListRequest) IsFiltered() bool
type ProblemQuery ¶
type ProblemSortField ¶
type ProblemSortField string
var ( ProblemSortFieldID ProblemSortField = "id" ProblemSortFieldSolverCount ProblemSortField = "solver_count" )
type ProblemStoredData ¶
type ProblemUserInfo ¶
type ProblemUserInfo struct { SolvedStatus SolvedStatus LastLanguage string Submissions []Submission }
type RegisterRequest ¶
type RegisterService ¶
type RegisterService interface {
Register(ctx context.Context, req RegisterRequest) (*User, error)
}
type SolvedStatus ¶
type SolvedStatus int
const ( Unattempted SolvedStatus = iota Attempted PartiallySolved Solved Unknown )
type SortDirection ¶
type SortDirection string
var ( SortASC SortDirection = "ASC" SortDESC SortDirection = "DESC" )
type Submission ¶
type Submission struct { ID int UserID int ProblemID int Language string Source []byte Private bool Started bool Verdict Verdict Ontest null.String Submitted time.Time Status problems.Status Judged null.Time Score float32 }
func NewSubmission ¶
func (*Submission) GetProblem ¶
func (*Submission) MarkForRejudge ¶
func (s *Submission) MarkForRejudge()
func (*Submission) SetSource ¶
func (s *Submission) SetSource(src []byte)
type SubmissionList ¶
type SubmissionList struct {
Submissions []Submission
}
type SubmissionListQuery ¶
type SubmissionListQuery interface { GetPagedSubmissionList(ctx context.Context, req SubmissionListRequest) (*PagedSubmissionList, error) GetSubmissionList(ctx context.Context, req SubmissionListRequest) (*SubmissionList, error) GetAttemptedSubmissionList(ctx context.Context, userID int) (*SubmissionList, error) GetSolvedSubmissionList(ctx context.Context, userID int) (*SubmissionList, error) }
type SubmissionListRequest ¶
type SubmissionListRequest struct { Problemset string Problem string SortDir SortDirection SortField SubmissionSortField Page int PerPage int Verdict *Verdict UserID int }
type SubmissionSortField ¶
type SubmissionSortField string
var ( SubmissionSortFieldID SubmissionSortField = "id" SubmissionSortFieldScore SubmissionSortField = "score" )
type Submissions ¶
type Submissions interface { Get(ctx context.Context, ID int) (*Submission, error) GetAll(ctx context.Context) ([]Submission, error) Insert(ctx context.Context, s Submission) (*Submission, error) Delete(ctx context.Context, ID int) error Update(ctx context.Context, s Submission, fields []string) error }
type SubmissionsQuery ¶
type SubmissionsQuery interface {
GetUnstarted(ctx context.Context, limit int) ([]Submission, error)
}
type SubmitRequest ¶
type SubmitService ¶
type SubmitService interface {
Submit(ctx context.Context, subRequest SubmitRequest) (*Submission, error)
}
type Tags ¶
type Tags interface { Get(ctx context.Context, ID int) (*Tag, error) GetByName(ctx context.Context, name string) (*Tag, error) GetAll(ctx context.Context) ([]Tag, error) Insert(ctx context.Context, p Tag) (*Tag, error) Delete(ctx context.Context, ID int) error Update(ctx context.Context, p Tag) error }
type TagsService ¶
type User ¶
type User struct { ID int Name string Password HashedPassword Email string ActivationInfo UserActivationInfo Role string Points float32 Settings UserSettings Created time.Time ForgottenPasswordKey *ForgottenPasswordKey }
func (*User) AuthenticatePassword ¶
func (*User) DeleteForgottenPasswordKey ¶
func (u *User) DeleteForgottenPasswordKey()
func (*User) SetForgottenPasswordKey ¶
func (u *User) SetForgottenPasswordKey(fpkey ForgottenPasswordKey)
func (*User) SetPassword ¶
type UserActivationInfo ¶
func GenerateActivationKey ¶
func GenerateActivationKey() UserActivationInfo
type UserSettings ¶
type UserSettings struct {
ShowUnsolvedTags bool
}
type Users ¶
type Users interface { Get(ctx context.Context, ID int) (*User, error) GetByName(ctx context.Context, name string) (*User, error) GetByEmail(ctx context.Context, email string) (*User, error) Insert(ctx context.Context, u User) (*User, error) Delete(ctx context.Context, ID int) error Update(ctx context.Context, user *User, fields []string) error }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.