Documentation ¶
Index ¶
- Constants
- Variables
- func Fields(s ...string) []string
- func GetUserPlaceInProblemsetRanklist(ctx context.Context, name string, userID int, ...) (int, error)
- type Categories
- type Category
- type CategoryFilter
- type CategoryFilterType
- type CodeVisibility
- type ForgottenPasswordKey
- type HashedPassword
- type Judge
- 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 ProblemTags
- type ProblemUserInfo
- type Problems
- type Problemset
- type ProblemsetRanklist
- type ProblemsetRanklistRequest
- type ProblemsetRanklistRow
- type ProblemsetRanklistService
- type Problemsets
- type RegisterRequest
- type SolvedStatus
- type SolvedStatusQuery
- 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 TaskArchiveNode
- type TaskArchiveNodeType
- type TaskArchiveService
- func (tas TaskArchiveService) CreateTopLevel(ctx context.Context, u *User) (*TaskArchiveNode, error)
- func (tas TaskArchiveService) CreateWithCategory(ctx context.Context, category Category, u *User) (*TaskArchiveNode, error)
- func (tas TaskArchiveService) CreateWithRoot(ctx context.Context, categories []Category, u *User, limit int) (*TaskArchiveNode, error)
- type User
- type UserActivationInfo
- type UserSettings
- type Users
- type Verdict
Constants ¶
View Source
const ( VerdictUnknown = Verdict(problems.VerdictUnknown) 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) VerdictSK = Verdict(problems.VerdictSK) VerdictCE Verdict = "CE" VerdictRU Verdict = "RU" VerdictUP Verdict = "UP" )
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 ErrorAlreadyActivated = errors.New("njudge: user already activated")
View Source
var (
ErrorCategoryNotFound = errors.New("njudge: category not found")
)
View Source
var ErrorProblemsetNotFound = errors.New("njudge: problemset 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 ErrorWrongActivationKey = errors.New("njudge: wrong activation key")
View Source
var ProblemFields = struct { ID string Problemset string Problem string Category string SolverCount string Visible string Author string Tags string }{ ID: "id", Problemset: "problemset", Problem: "problem", Category: "category", SolverCount: "solver_count", Visible: "visible", Author: "author", 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, SubmissionFields.Status, SubmissionFields.Verdict}
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 GetUserPlaceInProblemsetRanklist ¶ added in v0.6.0
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 CodeVisibility ¶ added in v0.6.0
type CodeVisibility string
const ( CodeVisibilityPrivate CodeVisibility = "private" CodeVisibilitySolved CodeVisibility = "solved" CodeVisibilityPublic CodeVisibility = "public" )
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 Visible bool Author string Tags ProblemTags }
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 User *User }
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 ¶
func (*ProblemStoredData) GetAttachment ¶
func (p *ProblemStoredData) GetAttachment(attachment string) (problems.NamedData, error)
func (*ProblemStoredData) GetLanguage ¶ added in v0.5.0
func (p *ProblemStoredData) GetLanguage(id string) language.Language
func (*ProblemStoredData) GetPDF ¶
func (p *ProblemStoredData) GetPDF(lang Language) (io.ReadCloser, error)
type ProblemTags ¶ added in v0.5.0
type ProblemTags []ProblemTag
func (ProblemTags) ToTags ¶ added in v0.5.0
func (p ProblemTags) ToTags() []Tag
type ProblemUserInfo ¶
type ProblemUserInfo struct { SolvedStatus SolvedStatus LastLanguage string Submissions []Submission }
type Problemset ¶ added in v0.6.0
type Problemset struct { Name string CodeVisibility CodeVisibility }
type ProblemsetRanklist ¶ added in v0.6.0
type ProblemsetRanklist struct { Rows []ProblemsetRanklistRow PaginationData PaginationData }
type ProblemsetRanklistRequest ¶ added in v0.6.0
type ProblemsetRanklistRow ¶ added in v0.6.0
type ProblemsetRanklistService ¶ added in v0.6.0
type ProblemsetRanklistService interface {
GetRanklist(ctx context.Context, req ProblemsetRanklistRequest) (*ProblemsetRanklist, error)
}
type Problemsets ¶ added in v0.6.0
type Problemsets interface { GetByName(ctx context.Context, problemsetName string) (*Problemset, error) GetAll(ctx context.Context) ([]Problemset, error) Insert(ctx context.Context, problemset Problemset) error }
type RegisterRequest ¶
type SolvedStatus ¶
type SolvedStatus string
const ( Unattempted SolvedStatus = "Unattempted" Attempted SolvedStatus = "Attempted" PartiallySolved SolvedStatus = "PartiallySolved" Solved SolvedStatus = "Solved" Unknown SolvedStatus = "Unknown" )
type SolvedStatusQuery ¶ added in v0.4.0
type SolvedStatusQuery interface {
GetSolvedStatus(ctx context.Context, problemID, userID int) (SolvedStatus, error)
}
type SortDirection ¶
type SortDirection string
const ( 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) GetACSubmissionsOf(ctx context.Context, problemID int) ([]Submission, error) }
type SubmitRequest ¶
type SubmitService ¶
type SubmitService struct {
// contains filtered or unexported fields
}
func NewSubmitService ¶ added in v0.5.0
func NewSubmitService(users Users, problemQuery ProblemQuery, problemStore problems.Store) *SubmitService
func (*SubmitService) Submit ¶
func (s *SubmitService) Submit(ctx context.Context, req 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 TaskArchiveNode ¶ added in v0.5.0
type TaskArchiveNode struct { ID int Type TaskArchiveNodeType Category *Category Problem *Problem SolvedStatus SolvedStatus Children []TaskArchiveNode Visible bool }
func (*TaskArchiveNode) Search ¶ added in v0.5.0
func (t *TaskArchiveNode) Search(f func(node *TaskArchiveNode) bool)
type TaskArchiveNodeType ¶ added in v0.5.0
type TaskArchiveNodeType string
const ( TaskArchiveNodeRoot TaskArchiveNodeType = "root" TaskArchiveNodeCategory TaskArchiveNodeType = "category" TaskArchiveNodeProblem TaskArchiveNodeType = "problem" )
type TaskArchiveService ¶ added in v0.5.0
type TaskArchiveService struct { Categories Categories Problems Problems SolvedStatusQuery SolvedStatusQuery ProblemQuery ProblemQuery ProblemStore problems.Store }
func (TaskArchiveService) CreateTopLevel ¶ added in v0.5.0
func (tas TaskArchiveService) CreateTopLevel(ctx context.Context, u *User) (*TaskArchiveNode, error)
func (TaskArchiveService) CreateWithCategory ¶ added in v0.5.0
func (tas TaskArchiveService) CreateWithCategory(ctx context.Context, category Category, u *User) (*TaskArchiveNode, error)
func (TaskArchiveService) CreateWithRoot ¶ added in v0.5.0
func (tas TaskArchiveService) CreateWithRoot(ctx context.Context, categories []Category, u *User, limit int) (*TaskArchiveNode, error)
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 RegisterUser ¶ added in v0.5.0
func (*User) ActivateWithKey ¶ added in v0.5.0
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) GetAll(ctx context.Context) ([]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.