Documentation ¶
Index ¶
- Constants
- Variables
- func AutoMigrate(db *gorm.DB) error
- func ClearTestcaseResult(db *gorm.DB, subID int32) error
- func Connect(dsn DSN, enableLogger bool) *gorm.DB
- func CreateTestDB(t *testing.T) *gorm.DB
- func FetchMetadata(db *gorm.DB, key string) (*string, error)
- func FinishTask(db *gorm.DB, taskId int32) error
- func PushHackTask(db *gorm.DB, id, priority int32) error
- func PushSubmissionTask(db *gorm.DB, id, priority int32) error
- func PushTask(db *gorm.DB, taskData TaskData, priority int32) error
- func RegisterUser(db *gorm.DB, name string, uid string) error
- func SaveHack(db *gorm.DB, h Hack) (int32, error)
- func SaveMetadata(db *gorm.DB, key string, value string) error
- func SaveProblem(db *gorm.DB, problem Problem) error
- func SaveProblemCategories(db *gorm.DB, categories []ProblemCategory) error
- func SaveSubmission(db *gorm.DB, submission Submission) (int32, error)
- func SaveTestcaseResult(db *gorm.DB, result SubmissionTestcaseResult) error
- func TouchTask(db *gorm.DB, id int32) error
- func UpdateHack(db *gorm.DB, h Hack) error
- func UpdateSubmission(db *gorm.DB, submission Submission) error
- func UpdateSubmissionStatus(db *gorm.DB, id int32, status string) error
- func UpdateUser(db *gorm.DB, user User) error
- type DSN
- type Hack
- type Metadata
- type Problem
- type ProblemCategory
- type Submission
- type SubmissionOrder
- type SubmissionOverView
- type SubmissionTestcaseResult
- type Task
- type TaskData
- type TaskType
- type User
Constants ¶
View Source
const (
MAX_TRY_TIMES = 3
)
View Source
const TASK_RETRY_PERIOD = time.Minute
Variables ¶
View Source
var DEFAULT_DSN = DSN{
Host: "localhost",
Port: 5432,
Database: "librarychecker",
User: "postgres",
Password: "lcdummypassword",
}
View Source
var ErrNotExist = errors.New("not exist")
Functions ¶
func AutoMigrate ¶
func SaveProblemCategories ¶
func SaveProblemCategories(db *gorm.DB, categories []ProblemCategory) error
func SaveSubmission ¶
func SaveSubmission(db *gorm.DB, submission Submission) (int32, error)
save submission and return id
func SaveTestcaseResult ¶
func SaveTestcaseResult(db *gorm.DB, result SubmissionTestcaseResult) error
func UpdateSubmission ¶
func UpdateSubmission(db *gorm.DB, submission Submission) error
func UpdateSubmissionStatus ¶
Types ¶
type DSN ¶
func GetDSNFromEnv ¶
func GetDSNFromEnv() DSN
type Hack ¶
type Hack struct { ID int32 `gorm:"primaryKey"` HackTime time.Time `gorm:"not null"` Submission Submission `gorm:"foreignKey:SubmissionID"` SubmissionID int32 User User `gorm:"foreignKey:UserName"` UserName sql.NullString // Test case, exactly one item is not nil TestCaseTxt []byte TestCaseCpp []byte // Result Status string Time sql.NullInt32 Memory sql.NullInt64 Stderr []byte JudgeOutput []byte }
Hack is db table
type Problem ¶
type Problem struct { Name string `gorm:"primaryKey"` Title string SourceUrl string Timelimit int32 TestCasesVersion string Version string }
Problem is db table
type ProblemCategory ¶
func FetchProblemCategories ¶
func FetchProblemCategories(db *gorm.DB) ([]ProblemCategory, error)
type Submission ¶
type Submission struct { ID int32 `gorm:"primaryKey"` SubmissionTime time.Time ProblemName string Problem Problem `gorm:"foreignKey:ProblemName"` Lang string Status string PrevStatus string Hacked bool Source string TestCasesVersion string MaxTime int32 MaxMemory int64 CompileError []byte UserName sql.NullString User User `gorm:"foreignKey:UserName"` JudgedTime time.Time }
Submission is db table
func FetchSubmission ¶
func FetchSubmission(db *gorm.DB, id int32) (Submission, error)
type SubmissionOrder ¶
type SubmissionOrder int
const ( ID_DESC SubmissionOrder = iota MAX_TIME_ASC )
type SubmissionOverView ¶
type SubmissionOverView struct { ID int32 SubmissionTime time.Time ProblemName string Problem Problem Lang string Status string TestCasesVersion string MaxTime int32 MaxMemory int64 UserName sql.NullString User User }
SubmissionOverview is smart select table
func FetchSubmissionList ¶
func FetchSubmissionList(db *gorm.DB, problem, status, lang, user string, dedupUser bool, order []SubmissionOrder, offset, limit int) ([]SubmissionOverView, int64, error)
func ToSubmissionOverView ¶
func ToSubmissionOverView(s Submission) SubmissionOverView
type SubmissionTestcaseResult ¶
type SubmissionTestcaseResult struct { Submission int32 `gorm:"primaryKey"` // TODO: should be foreign key Testcase string `gorm:"primaryKey"` Status string Time int32 Memory int64 Stderr []byte CheckerOut []byte }
SubmissionTestcaseResult is db table
func FetchTestcaseResults ¶
func FetchTestcaseResults(db *gorm.DB, id int32) ([]SubmissionTestcaseResult, error)
type Task ¶
type Task struct { ID int32 `gorm:"primaryKey;autoIncrement"` Priority int32 Available time.Time Enqueue time.Time TaskData []byte }
Task is db table
Click to show internal directories.
Click to hide internal directories.