feat(tester): migrate from gRPC to REST
This commit is contained in:
parent
6613b03b6c
commit
a560715ae8
40 changed files with 403 additions and 961 deletions
|
@ -1,13 +1,13 @@
|
|||
package models
|
||||
|
||||
type Language struct {
|
||||
Name string
|
||||
CompileCmd []string //source: src;result:executable
|
||||
RunCmd []string //source: executable
|
||||
}
|
||||
|
||||
var Languages = [...]Language{
|
||||
{Name: "gcc std=c90",
|
||||
CompileCmd: []string{"gcc", "src", "-std=c90", "-o", "executable"},
|
||||
RunCmd: []string{"executable"}},
|
||||
}
|
||||
//type Language struct {
|
||||
// Name string
|
||||
// CompileCmd []string //source: src;result:executable
|
||||
// RunCmd []string //source: executable
|
||||
//}
|
||||
//
|
||||
//var Languages = []Language{
|
||||
// {Name: "gcc std=c90",
|
||||
// CompileCmd: []string{"gcc", "src", "-std=c90", "-o", "executable"},
|
||||
// RunCmd: []string{"executable"}},
|
||||
//}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Participant struct {
|
||||
Id *int32 `db:"id"`
|
||||
UserId *int32 `db:"user_id"`
|
||||
ContestId *int32 `db:"contest_id"`
|
||||
Name *string `db:"name"`
|
||||
CreatedAt *time.Time `db:"created_at"`
|
||||
UpdatedAt *time.Time `db:"updated_at"`
|
||||
}
|
||||
//type Participant struct {
|
||||
// Id *int32 `db:"id"`
|
||||
// UserId *int32 `db:"user_id"`
|
||||
// ContestId *int32 `db:"contest_id"`
|
||||
// Name *string `db:"name"`
|
||||
// CreatedAt *time.Time `db:"created_at"`
|
||||
// UpdatedAt *time.Time `db:"updated_at"`
|
||||
//}
|
||||
|
|
|
@ -1,30 +1,26 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Result int32
|
||||
|
||||
const (
|
||||
NotTested Result = 1 // change only with schema change
|
||||
Accepted Result = 2
|
||||
WrongAnswer Result = 3
|
||||
PresentationError Result = 4
|
||||
CompilationError Result = 5
|
||||
MemoryLimitExceeded Result = 6
|
||||
TimeLimitExceeded Result = 7
|
||||
RuntimeError Result = 8
|
||||
SystemFailDuringTesting Result = 9
|
||||
Testing Result = 10
|
||||
)
|
||||
|
||||
var ErrBadResult = errors.New("bad result")
|
||||
|
||||
func (result Result) Valid() error {
|
||||
switch result {
|
||||
case NotTested, Accepted, TimeLimitExceeded, MemoryLimitExceeded, CompilationError, SystemFailDuringTesting:
|
||||
return nil
|
||||
}
|
||||
return ErrBadResult
|
||||
}
|
||||
//type Result int32
|
||||
//
|
||||
//const (
|
||||
// NotTested Result = 1 // change only with schema change
|
||||
// Accepted Result = 2
|
||||
// WrongAnswer Result = 3
|
||||
// PresentationError Result = 4
|
||||
// CompilationError Result = 5
|
||||
// MemoryLimitExceeded Result = 6
|
||||
// TimeLimitExceeded Result = 7
|
||||
// RuntimeError Result = 8
|
||||
// SystemFailDuringTesting Result = 9
|
||||
// Testing Result = 10
|
||||
//)
|
||||
//
|
||||
//var ErrBadResult = errors.New("bad result")
|
||||
//
|
||||
//func (result Result) Valid() error {
|
||||
// switch result {
|
||||
// case NotTested, Accepted, TimeLimitExceeded, MemoryLimitExceeded, CompilationError, SystemFailDuringTesting:
|
||||
// return nil
|
||||
// }
|
||||
// return ErrBadResult
|
||||
//}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Role int32
|
||||
|
||||
const (
|
||||
RoleSpectator Role = 0
|
||||
RoleParticipant Role = 1
|
||||
RoleModerator Role = 2
|
||||
RoleAdmin Role = 3
|
||||
)
|
||||
|
||||
func (role Role) IsAdmin() bool {
|
||||
return role == RoleAdmin
|
||||
}
|
||||
|
||||
func (role Role) IsModerator() bool {
|
||||
return role == RoleModerator
|
||||
}
|
||||
|
||||
func (role Role) IsParticipant() bool {
|
||||
return role == RoleParticipant
|
||||
}
|
||||
|
||||
func (role Role) IsSpectator() bool {
|
||||
return role == RoleSpectator
|
||||
}
|
||||
|
||||
func (role Role) AtLeast(other Role) bool {
|
||||
return role >= other
|
||||
}
|
||||
|
||||
func (role Role) AtMost(other Role) bool {
|
||||
return role <= other
|
||||
}
|
||||
|
||||
var ErrBadRole = errors.New("bad role")
|
||||
|
||||
func (role Role) Valid() error {
|
||||
switch role {
|
||||
case RoleSpectator, RoleParticipant, RoleModerator, RoleAdmin:
|
||||
return nil
|
||||
}
|
||||
return ErrBadRole
|
||||
}
|
||||
|
||||
func (role Role) AsPointer() *Role {
|
||||
return &role
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Solution struct {
|
||||
Id *int32 `db:"id"`
|
||||
TaskId *int32 `db:"task_id"`
|
||||
ParticipantId *int32 `db:"participant_id"`
|
||||
State *int32 `db:"state"`
|
||||
Score *int32 `db:"score"`
|
||||
Penalty *int32 `db:"penalty"`
|
||||
TotalScore *int32 `db:"total_score"`
|
||||
Language *int32 `db:"language"`
|
||||
CreatedAt *time.Time `db:"created_at"`
|
||||
}
|
||||
//type Solution struct {
|
||||
// Id *int32 `db:"id"`
|
||||
// TaskId *int32 `db:"task_id"`
|
||||
// ParticipantId *int32 `db:"participant_id"`
|
||||
// State *int32 `db:"state"`
|
||||
// Score *int32 `db:"score"`
|
||||
// Penalty *int32 `db:"penalty"`
|
||||
// TotalScore *int32 `db:"total_score"`
|
||||
// Language *int32 `db:"language"`
|
||||
// CreatedAt *time.Time `db:"created_at"`
|
||||
//}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Task struct {
|
||||
Id *int32 `db:"id"`
|
||||
ProblemId *int32 `db:"problem_id"`
|
||||
ContestId *int32 `db:"contest_id"`
|
||||
Position *int32 `db:"position"`
|
||||
CreatedAt *time.Time `db:"created_at"`
|
||||
UpdatedAt *time.Time `db:"updated_at"`
|
||||
}
|
||||
//type Task struct {
|
||||
// Id *int32 `db:"id"`
|
||||
// ProblemId *int32 `db:"problem_id"`
|
||||
// ContestId *int32 `db:"contest_id"`
|
||||
// Position *int32 `db:"position"`
|
||||
// CreatedAt *time.Time `db:"created_at"`
|
||||
// UpdatedAt *time.Time `db:"updated_at"`
|
||||
//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue