Documentation ¶
Index ¶
- Constants
- func UpdateTest(test *Test, request *UpdateTestRequest)
- type Api
- type Command
- type Config
- type CreateProblemRequest
- type CreateSubmissionRequest
- type CreateTestRequest
- type Database
- type Eval
- type ExecuteRequest
- type FullTest
- type Language
- type LoginRequest
- type Problem
- type ProblemDifficulty
- type ProblemFilter
- type ProblemGrade
- type Server
- type SignupRequest
- type StreamFlag
- type Submission
- type SubmissionFilter
- type SubmissionLang
- type SubmissionStatus
- type SubmissionTest
- type Test
- type UpdateProblemRequest
- type UpdateSubmissionRequest
- type UpdateSubmissionTestRequest
- type UpdateTestRequest
- type User
Constants ¶
View Source
const ( Waiting = SubmissionStatus("waiting") Working = SubmissionStatus("working") Finished = SubmissionStatus("finished") )
View Source
const C = SubmissionLang("c")
Variables ¶
This section is empty.
Functions ¶
func UpdateTest ¶
func UpdateTest(test *Test, request *UpdateTestRequest)
Types ¶
type Config ¶
type Config struct { Database `json:"database"` Server `json:"server"` Api `json:"api"` Eval `json:"eval"` Languages map[string]Language `json:"languages"` }
Config is the struct behind the config.json file. It holds basic configurations for the server to run
type CreateProblemRequest ¶
type CreateProblemRequest struct { Name string `json:"name"` Description string `json:"description"` ShortDescription string `json:"shortDescription"` Visible bool `json:"visible"` Difficulty ProblemDifficulty `json:"difficulty"` Grade ProblemGrade `json:"grade"` Credits string `json:"credits"` Stream StreamFlag `json:"stream"` TimeLimit float64 `json:"timeLimit"` MemoryLimit int `json:"memoryLimit"` StackLimit int `json:"stackLimit"` SourceSize int `json:"sourceSize"` }
func (CreateProblemRequest) Validate ¶
func (data CreateProblemRequest) Validate() error
type CreateSubmissionRequest ¶
type CreateSubmissionRequest struct { Lang SubmissionLang `json:"lang"` ProblemId int `json:"problemId"` SourceCode string `json:"sourceCode"` }
func (CreateSubmissionRequest) Validate ¶
func (data CreateSubmissionRequest) Validate() error
type CreateTestRequest ¶
type CreateTestRequest struct { ProblemId int `json:"problemId"` Score int `json:"score"` Input []byte `json:"input"` Output []byte `json:"output"` }
func (CreateTestRequest) Validate ¶
func (data CreateTestRequest) Validate() error
type Eval ¶
type Eval struct { IsolatePath string `json:"isolatePath"` // Concurrency stuff MaxSandboxes int `json:"maxSandboxes"` MaxCompile int `json:"maxCompile"` MaxExecute int `json:"maxExecute"` MaxCheck int `json:"maxCheck"` CompilePath string `json:"compilePath"` OutputPath string `json:"outputPath"` LoggerPath string `json:"loggerPath"` }
type ExecuteRequest ¶
type FullTest ¶
type FullTest struct { Test `json:"test"` Input string `json:"input"` Output string `json:"output"` }
FullTest is an extended Test that has input and output fields.
func NewFullTest ¶
type LoginRequest ¶
func (LoginRequest) Validate ¶
func (data LoginRequest) Validate() error
type Problem ¶
type Problem struct { Id uint64 `json:"id"` CreatedAt *time.Time `json:"createdAt" db:"created_at"` Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` ShortDescription string `json:"shortDescription" db:"short_description"` AuthorId uint64 `json:"authorId" db:"author_id"` Visible bool `json:"visible" db:"visible"` Difficulty ProblemDifficulty `json:"difficulty" db:"difficulty"` Grade ProblemGrade `json:"grade" db:"grade"` Credits string `json:"credits" db:"credits"` Stream StreamFlag `json:"stream" db:"stream"` TimeLimit float64 `json:"timeLimit" db:"time_limit"` MemoryLimit int `json:"memoryLimit" db:"memory_limit"` StackLimit int `json:"stackLimit" db:"stack_limit"` SourceSize int `json:"sourceSize" db:"source_size"` }
func NewProblem ¶
func NewProblem(request CreateProblemRequest) *Problem
func (Problem) IsConsoleProblem ¶
type ProblemDifficulty ¶
type ProblemDifficulty string
const ( Easy ProblemDifficulty = "easy" Medium ProblemDifficulty = "medium" Hard ProblemDifficulty = "hard" Contest ProblemDifficulty = "contest" )
type ProblemFilter ¶
type ProblemFilter struct { AuthorsId []int Difficulties []string Credits []string Stream []string Grades []string }
func ParseProblemFilter ¶
func ParseProblemFilter(r *http.Request) *ProblemFilter
type ProblemGrade ¶
type ProblemGrade string
ex. clasa a 9, clasa a 10 etc
const ( NINE ProblemGrade = "9" TEN ProblemGrade = "10" ELEVEN ProblemGrade = "11" )
type SignupRequest ¶
type SignupRequest struct { Username string `json:"username"` Email string `json:"email"` Password string `json:"password"` }
func (SignupRequest) Validate ¶
func (data SignupRequest) Validate() error
type StreamFlag ¶
type StreamFlag string
const ( CONSOLE StreamFlag = "console" FILE StreamFlag = "file" )
type Submission ¶
type Submission struct { Id uint64 `json:"id"` CreatedAt *time.Time `json:"createdAt" db:"created_at"` Score int `json:"score"` Lang SubmissionLang `json:"lang"` Status SubmissionStatus `json:"status"` Message string `json:"message"` HasCompileError *bool `json:"hasCompileError" db:"has_compile_error"` ProblemId int `json:"problemId" db:"problem_id"` UserId int `json:"userId" db:"user_id"` SourceCode string `json:"sourceCode" db:"source_code"` }
func NewSubmission ¶
func NewSubmission(request CreateSubmissionRequest, userId int) *Submission
type SubmissionFilter ¶
type SubmissionFilter struct { UserId int ProblemId int Score int Langs []SubmissionLang Statuses []SubmissionStatus CompileError *bool // nil == skip(does not matter), false no compile error, true compile errors }
func ParseSubmissionFilter ¶
func ParseSubmissionFilter(r *http.Request) *SubmissionFilter
type SubmissionLang ¶
type SubmissionLang string
type SubmissionStatus ¶
type SubmissionStatus string
type SubmissionTest ¶
type SubmissionTest struct { Id uint64 `json:"id"` EvaluatedAt *time.Time `json:"evaluatedAt" db:"evaluated_at"` Score int `json:"score"` Time float64 `json:"time"` Memory int `json:"memory"` // in kb Message string `json:"message"` ExitCode int `json:"exitCode" db:"exit_code"` SubmissionId uint64 `json:"submissionId" db:"submission_id"` TestId uint64 `json:"testId" db:"test_id"` }
func NewSubmissionTest ¶
func NewSubmissionTest(submissionId, testId uint64) *SubmissionTest
type Test ¶
type Test struct { Id uint64 `json:"id" db:"id"` CreatedAt *time.Time `json:"createdAt" db:"created_at"` ProblemId int `json:"problemId" db:"problem_id"` Score int `json:"score" db:"score"` }
func NewTest ¶
func NewTest(request CreateTestRequest) *Test
type UpdateProblemRequest ¶
type UpdateProblemRequest struct { Name string `json:"name"` Description string `json:"description"` ShortDescription string `json:"shortDescription"` AuthorId uint64 `json:"authorId"` Visible bool `json:"visible"` Difficulty ProblemDifficulty `json:"difficulty"` Grade ProblemGrade `json:"grade"` Credits string `json:"credits"` Stream StreamFlag `json:"stream"` // TODO the validation is broken TimeLimit float64 `json:"timeLimit"` MemoryLimit int `json:"memoryLimit"` StackLimit int `json:"stackLimit"` SourceSize int `json:"sourceSize"` }
type UpdateSubmissionRequest ¶
type UpdateSubmissionRequest struct { Score int Status SubmissionStatus Message string HasCompileError *bool }
func NewUpdateSubmissionRequest ¶
func NewUpdateSubmissionRequest(score int, status SubmissionStatus, message string, compileError *bool) *UpdateSubmissionRequest
type UpdateTestRequest ¶
type UpdateTestRequest struct { Score int `json:"score"` Input []byte `json:"input"` Output []byte `json:"output"` }
TODO add input and output validation
func (UpdateTestRequest) Validate ¶
func (data UpdateTestRequest) Validate() error
type User ¶
type User struct { Id uint64 `json:"id"` CreatedAt *time.Time `json:"createdAt" db:"created_at"` Username string `json:"username"` Email string `json:"email"` Password string `json:"-"` Bio string `json:"bio"` Visible bool `json:"visible"` IsAdmin bool `json:"isAdmin" db:"is_admin"` IsProposer bool `json:"isProposer" db:"is_proposer"` IsBanned bool `json:"isBanned" db:"is_banned"` VerifiedEmail bool `json:"verifiedEmail" db:"verified_email"` EmailVerificationSentAt *time.Time `json:"emailVerificationSentAt" db:"email_verification_sent_at"` }
User represents a user entity
Click to show internal directories.
Click to hide internal directories.