database

package
v0.0.0-...-263a686 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2017 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const RankingNumberOfNotProblem = 6
View Source
const RelatedFilesPerProblem = 5

Variables

View Source
var ErrAlreadyTransactionBegun = errors.New("Transaction is already begun")
View Source
var ErrIllegalQuery = errors.New("Illegal Query")
View Source
var ErrKeyDuplication = errors.New("Key Duplication")
View Source
var ErrNotRegisteredRankingCell = errors.New("Not registered ranking cell")
View Source
var ErrUnknownContest = errors.New("Unknown contest")
View Source
var ErrUnknownGroup = errors.New("Unknown group")
View Source
var ErrUnknownLanguage = errors.New("Unknown language")
View Source
var ErrUnknownProblem = errors.New("Unknown problem")

Error templates

View Source
var ErrUnknownRankingCell = errors.New("Unknown ranking cell")
View Source
var ErrUnknownRankingRow = errors.New("Unknown ranking row")
View Source
var ErrUnknownSession = errors.New("Unknown session")
View Source
var ErrUnknownSubmission = errors.New("Unknown submission")
View Source
var ErrUnknownTestcase = errors.New("Unknown testcase")
View Source
var ErrUnknownUser = errors.New("Unknown user")

Functions

func IsAlreadyExistsError

func IsAlreadyExistsError(err error) bool

func IsDuplicateError

func IsDuplicateError(err error) bool

func ParseRankingCell

func ParseRankingCell(str string) *sctypes.RankingCell

Types

type CheckerSavedFormat

type CheckerSavedFormat struct {
	Lid  int64
	Code string
}

type Contest

type Contest struct {
	Cid             int64               `gorm:"primary_key"`
	Name            string              `gorm:"not null;unique_index"`
	StartTime       time.Time           `gorm:"not null;default:CURRENT_TIMESTAMP;index"`
	FinishTime      time.Time           `gorm:"not null;default:CURRENT_TIMESTAMP;index"`
	Admin           int64               `gorm:"not null"`
	Penalty         int64               `gorm:"not null"`
	Type            sctypes.ContestType `gorm:"not null"`
	DescriptionFile string              `gorm:"not null"`
	// contains filtered or unexported fields
}

func (*Contest) DescriptionLoad

func (c *Contest) DescriptionLoad() (string, error)

func (*Contest) DescriptionUpdate

func (c *Contest) DescriptionUpdate(desc string) error

func (*Contest) ProblemAdd

func (c *Contest) ProblemAdd(pidx int64, name string, time, mem int64, jtype sctypes.JudgeType, newlineCharConversion bool) (*ContestProblem, error)

type ContestParticipation

type ContestParticipation struct {
	Cpid  int64 `gorm:"primary_key"`
	Iid   int64 `gorm:"index"`
	Cid   int64 `gorm:"index"`
	Admin bool
}

type ContestProblem

type ContestProblem struct {
	Pid                   int64                    `gorm:"primary_key"`
	Cid                   int64                    `gorm:"-"` //`gorm:"not null;index;unique_index:cid_and_pidx_index"`
	Pidx                  int64                    `gorm:"not null;index;unique_index:cid_and_pidx_index"`
	Name                  string                   `gorm:"not null;size:255"`
	Time                  int64                    `gorm:"not null"` // Second
	Mem                   int64                    `gorm:"not null"` // MB
	LastModified          int64                    `gorm:"not null"`
	Score                 int64                    `gorm:"not null"`
	Type                  sctypes.JudgeType        `gorm:"not null"`
	NewlineCharConversion bool                     `gorm:"not null;default: true"`
	StatementFile         string                   `gorm:"not null;size:127"`
	CheckerFile           string                   `gorm:"not null;size:127"`
	RelatedFilesStr       string                   `gorm:"not null;size:1023"`
	RelatedFiles          []string                 `gorm:"-"`
	Cases                 []ContestProblemTestCase `gorm:"ForeignKey:Pid"`
	Scores                []ContestProblemScoreSet `gorm:"ForeignKey:Pid"`
	// contains filtered or unexported fields
}

func (*ContestProblem) AfterFind

func (cp *ContestProblem) AfterFind()

func (*ContestProblem) CreateUniquelyNamedFile

func (cp *ContestProblem) CreateUniquelyNamedFile() (*mgo.GridFile, error)

func (*ContestProblem) LoadChecker

func (cp *ContestProblem) LoadChecker() (lid int64, code string, ret error)

func (*ContestProblem) LoadStatement

func (cp *ContestProblem) LoadStatement() (string, error)

func (*ContestProblem) LoadTestCase

func (cp *ContestProblem) LoadTestCase(isInput bool, caseID int) (io.ReadCloser, error)

func (*ContestProblem) LoadTestCaseInfo

func (cp *ContestProblem) LoadTestCaseInfo(caseID int64) (int64, int64, error)

func (*ContestProblem) LoadTestCaseNames

func (cp *ContestProblem) LoadTestCaseNames() ([]string, []ContestProblemScoreSet, error)

func (*ContestProblem) LoadTestCases

func (ContestProblem) TableName

func (cp ContestProblem) TableName() string

func (*ContestProblem) UpdateChecker

func (cp *ContestProblem) UpdateChecker(lid int64, code string) error

func (*ContestProblem) UpdateStatement

func (cp *ContestProblem) UpdateStatement(text string) error

func (*ContestProblem) UpdateTestCase

func (cp *ContestProblem) UpdateTestCase(isInput bool, caseID int64, reader io.Reader) error

ErrUnknownTestcase

func (*ContestProblem) UpdateTestCaseNames

func (cp *ContestProblem) UpdateTestCaseNames(newCaseNames []string, newScores []ContestProblemScoreSet) error

type ContestProblemScoreSet

type ContestProblemScoreSet struct {
	Id             int64 `gorm:"primary_key"`
	Pid            int64
	CasesRawString string `gorm:"size:6143"`
	Score          int64
	Cases          ContestProblemScoreSetCasesString `gorm:"-"`
	Cid            int64                             `gorm:"-"`
}

func (*ContestProblemScoreSet) AfterFind

func (ss *ContestProblemScoreSet) AfterFind() error

func (*ContestProblemScoreSet) BeforeSave

func (ss *ContestProblemScoreSet) BeforeSave() error

func (ContestProblemScoreSet) TableName

func (cpss ContestProblemScoreSet) TableName() string

type ContestProblemScoreSetCasesString

type ContestProblemScoreSetCasesString string

func (*ContestProblemScoreSetCasesString) Get

func (*ContestProblemScoreSetCasesString) Set

type ContestProblemTestCase

type ContestProblemTestCase struct {
	Id     int64 `gorm:"primary_key"`
	Pid    int64
	Name   string `gorm:"size:128"`
	Input  string `gorm:"size:128"`
	Output string `gorm:"size:128"`
	Cid    int64  `gorm:"-"`
}

func (ContestProblemTestCase) TableName

func (cptc ContestProblemTestCase) TableName() string

type DatabaseManager

type DatabaseManager struct {
	// contains filtered or unexported fields
}

DatabaseManager is a connector to this database

func NewDatabaseManager

func NewDatabaseManager(addr string, debugMode bool, fs *fs.MongoFSManager, redis *redis.RedisManager, logger func() *logrus.Entry) (*DatabaseManager, error)

NewDatabaseManager is a function to initialize database connections static function

func (*DatabaseManager) Begin

func (dm *DatabaseManager) Begin(f func(db *gorm.DB) error) error

func (*DatabaseManager) BeginDM

func (dm *DatabaseManager) BeginDM(f func(dm *DatabaseManager) error) (ret error)

func (*DatabaseManager) BeginDMIfNotStarted

func (dm *DatabaseManager) BeginDMIfNotStarted(f func(dm *DatabaseManager) error) error

func (*DatabaseManager) BeginIfNotStarted

func (dm *DatabaseManager) BeginIfNotStarted(f func(dm *gorm.DB) error) error

func (*DatabaseManager) ClearUnassociatedData

func (dm *DatabaseManager) ClearUnassociatedData(cid int64) error

func (*DatabaseManager) Clone

func (dm *DatabaseManager) Clone(db *gorm.DB) *DatabaseManager

func (*DatabaseManager) Close

func (dm *DatabaseManager) Close()

func (*DatabaseManager) ContestAdd

func (dm *DatabaseManager) ContestAdd(name string, start time.Time, finish time.Time, admin int64, ctype sctypes.ContestType, penalty int64, backgroundPreparation func(cid int64) error) (*Contest, error)

func (*DatabaseManager) ContestCount

func (dm *DatabaseManager) ContestCount(options ...[]interface{}) (int64, error)

func (*DatabaseManager) ContestDelete

func (dm *DatabaseManager) ContestDelete(cid int64) error

func (*DatabaseManager) ContestFind

func (dm *DatabaseManager) ContestFind(cid int64) (*Contest, error)

func (*DatabaseManager) ContestGetType

func (dm *DatabaseManager) ContestGetType(cid int64) (sctypes.ContestType, error)

func (*DatabaseManager) ContestList

func (dm *DatabaseManager) ContestList(offset, limit int, options ...[]interface{}) (*[]Contest, error)

ContestList : if "offset" and "limit" aren't neccesary, set -1

func (*DatabaseManager) ContestParticipationAdd

func (dm *DatabaseManager) ContestParticipationAdd(iid, cid int64) error

func (*DatabaseManager) ContestParticipationAddAsAdmin

func (dm *DatabaseManager) ContestParticipationAddAsAdmin(iid, cid int64) error

func (*DatabaseManager) ContestParticipationCheck

func (dm *DatabaseManager) ContestParticipationCheck(iid, cid int64) (bool, bool, error)

ContestParticipationCheck returns (has joined, is admin, error)

func (*DatabaseManager) ContestParticipationDelete

func (dm *DatabaseManager) ContestParticipationDelete(iid, cid int64) error

func (*DatabaseManager) ContestParticipationRemove

func (dm *DatabaseManager) ContestParticipationRemove(cid int64) error

func (*DatabaseManager) ContestProblemAdd

func (dm *DatabaseManager) ContestProblemAdd(cid, pidx int64, name string, timeLimit, mem int64, jtype sctypes.JudgeType, newlineCharConversion bool) (int64, error)

func (*DatabaseManager) ContestProblemAutoMigrate

func (dm *DatabaseManager) ContestProblemAutoMigrate(cid int64) error

func (*DatabaseManager) ContestProblemCount

func (dm *DatabaseManager) ContestProblemCount(cid int64) (int64, error)

func (*DatabaseManager) ContestProblemDelete

func (dm *DatabaseManager) ContestProblemDelete(cid, pid int64) error

func (*DatabaseManager) ContestProblemDeleteAll

func (dm *DatabaseManager) ContestProblemDeleteAll(cid int64) error

func (*DatabaseManager) ContestProblemFind

func (dm *DatabaseManager) ContestProblemFind(cid, pid int64) (*ContestProblem, error)

func (*DatabaseManager) ContestProblemFind2

func (dm *DatabaseManager) ContestProblemFind2(cid, pidx int64) (*ContestProblem, error)

func (*DatabaseManager) ContestProblemList

func (dm *DatabaseManager) ContestProblemList(cid int64) ([]ContestProblem, error)

func (*DatabaseManager) ContestProblemListLight

func (dm *DatabaseManager) ContestProblemListLight(cid int64) ([]ContestProblem, error)

func (*DatabaseManager) ContestProblemRemoveAllWithTable

func (dm *DatabaseManager) ContestProblemRemoveAllWithTable(cid int64) error

func (*DatabaseManager) ContestProblemUpdate

func (dm *DatabaseManager) ContestProblemUpdate(prob ContestProblem) error

func (*DatabaseManager) ContestProblemUpdateRelatedFile

func (dm *DatabaseManager) ContestProblemUpdateRelatedFile(cid, pidx, idx int64, reader io.Reader) error

func (*DatabaseManager) ContestUpdate

func (dm *DatabaseManager) ContestUpdate(cid int64, name string, start time.Time, finish time.Time, admin int64, ctype sctypes.ContestType, penalty int64) error

func (*DatabaseManager) CreateContestParticipationTable

func (dm *DatabaseManager) CreateContestParticipationTable() error

func (*DatabaseManager) CreateContestProblemTable

func (dm *DatabaseManager) CreateContestProblemTable() error

func (*DatabaseManager) CreateContestTable

func (dm *DatabaseManager) CreateContestTable() error

func (*DatabaseManager) CreateGroupTable

func (dm *DatabaseManager) CreateGroupTable() error

func (*DatabaseManager) CreateLanguageTable

func (dm *DatabaseManager) CreateLanguageTable() error

func (*DatabaseManager) CreateNewsTable

func (dm *DatabaseManager) CreateNewsTable() error

func (*DatabaseManager) CreateRankingTable

func (dm *DatabaseManager) CreateRankingTable() error

func (*DatabaseManager) CreateSessionTable

func (dm *DatabaseManager) CreateSessionTable() error

func (*DatabaseManager) CreateSubmissionTable

func (dm *DatabaseManager) CreateSubmissionTable() error

func (*DatabaseManager) CreateUserTable

func (dm *DatabaseManager) CreateUserTable() error

func (*DatabaseManager) DB

func (dm *DatabaseManager) DB() *gorm.DB

func (*DatabaseManager) GetSessionTemplateData

func (dm *DatabaseManager) GetSessionTemplateData(sessionKey string) (*SessionTemplateData, error)

GetSessionTemplateData returns a SessionTemplateData object

func (*DatabaseManager) GetSessionUserData

func (dm *DatabaseManager) GetSessionUserData(sessionID string) (*User, error)

GetSessionUserData returns an User object

func (*DatabaseManager) GroupAdd

func (dm *DatabaseManager) GroupAdd(name string) (int64, error)

GroupAdd adds a new group len(groupName) <= 50

func (*DatabaseManager) GroupFind

func (dm *DatabaseManager) GroupFind(gid int64) (*Group, error)

GroupFind finds a group with groupID

func (*DatabaseManager) GroupList

func (dm *DatabaseManager) GroupList() ([]Group, error)

func (*DatabaseManager) GroupRemove

func (dm *DatabaseManager) GroupRemove(gid int64) error

GroupRemove removes from groups

func (*DatabaseManager) LanguageActiveList

func (dm *DatabaseManager) LanguageActiveList() ([]Language, error)

func (*DatabaseManager) LanguageAdd

func (dm *DatabaseManager) LanguageAdd(name, highlightType string, active bool) (int64, error)

func (*DatabaseManager) LanguageFind

func (dm *DatabaseManager) LanguageFind(lid int64) (*Language, error)

func (*DatabaseManager) LanguageList

func (dm *DatabaseManager) LanguageList() ([]Language, error)

func (*DatabaseManager) LanguageUpdate

func (dm *DatabaseManager) LanguageUpdate(lid int64, name, highlightType string, active bool) error

func (*DatabaseManager) Logger

func (dm *DatabaseManager) Logger() *logrus.Entry

func (*DatabaseManager) NewsAdd

func (dm *DatabaseManager) NewsAdd(text string) error

NewsAdd adds a news displayed on "/" len(text) <= 256

func (*DatabaseManager) NewsAddWithTime

func (dm *DatabaseManager) NewsAddWithTime(text string, unixTime time.Time) error

NewsAddWithTime adds a news displayed on "/" with unixtime len(text) <= 256

func (*DatabaseManager) NewsGet

func (dm *DatabaseManager) NewsGet(cnt int) ([]News, error)

func (*DatabaseManager) RankingAutoMigrate

func (dm *DatabaseManager) RankingAutoMigrate(cid int64) error

func (*DatabaseManager) RankingCellName

func (dm *DatabaseManager) RankingCellName(pid int64) string

func (*DatabaseManager) RankingCellUpdate

func (dm *DatabaseManager) RankingCellUpdate(cid, iid, pid int64, rc sctypes.RankingCell) error

func (*DatabaseManager) RankingCount

func (dm *DatabaseManager) RankingCount(cid int64) (int64, error)

func (*DatabaseManager) RankingDelete

func (dm *DatabaseManager) RankingDelete(cid int64) error

func (*DatabaseManager) RankingGeneralUpdate

func (dm *DatabaseManager) RankingGeneralUpdate(cid, iid int64, value1, value2 int64, rc sctypes.RankingCell) error

func (*DatabaseManager) RankingGetAll

func (dm *DatabaseManager) RankingGetAll(cid, offset, limit int64) ([]sctypes.RankingRow, error)

func (*DatabaseManager) RankingGetAllWithUserData

func (dm *DatabaseManager) RankingGetAllWithUserData(cid, offset, limit int64) ([]sctypes.RankingRowWithUserData, error)

func (*DatabaseManager) RankingGetCell

func (dm *DatabaseManager) RankingGetCell(cid, iid, pid int64) (*sctypes.RankingCell, error)

func (*DatabaseManager) RankingGetCellAndGeneral

func (dm *DatabaseManager) RankingGetCellAndGeneral(cid, iid, pid int64) (*sctypes.RankingCell, *sctypes.RankingCell, error)

func (*DatabaseManager) RankingGetRow

func (dm *DatabaseManager) RankingGetRow(cid, iid int64) (*sctypes.RankingRow, error)

func (*DatabaseManager) RankingProblemAdd

func (dm *DatabaseManager) RankingProblemAdd(cid, pid int64) error

func (*DatabaseManager) RankingProblemDelete

func (dm *DatabaseManager) RankingProblemDelete(cid, pid int64) error

func (*DatabaseManager) RankingTableName

func (dm *DatabaseManager) RankingTableName(cid int64) string

func (*DatabaseManager) RankingUpdate

func (dm *DatabaseManager) RankingUpdate(cid, iid, pid int64, rc sctypes.RankingCell) error

func (*DatabaseManager) RankingUserAdd

func (dm *DatabaseManager) RankingUserAdd(cid, iid int64) error

func (*DatabaseManager) SessionAdd

func (dm *DatabaseManager) SessionAdd(internalID int64) (string, error)

SessionAdd adds a new session

func (*DatabaseManager) SessionFind

func (dm *DatabaseManager) SessionFind(sessionKey string) (*Session, error)

SessionFind is to find a session len(sessionID) = 32

func (*DatabaseManager) SessionRemove

func (dm *DatabaseManager) SessionRemove(sessionKey string) error

SessionRemove is to remove session len(sessionKey) = 32

func (*DatabaseManager) SubmissionAdd

func (dm *DatabaseManager) SubmissionAdd(cid, pid, iid, lang int64, code string) (i int64, b error)

func (*DatabaseManager) SubmissionAppendCase

func (dm *DatabaseManager) SubmissionAppendCase(cid, sid int64, stc SubmissionTestCase) error

func (*DatabaseManager) SubmissionAutoMigrate

func (dm *DatabaseManager) SubmissionAutoMigrate(cid int64) error

func (*DatabaseManager) SubmissionClearCase

func (dm *DatabaseManager) SubmissionClearCase(cid, sid int64) error

func (*DatabaseManager) SubmissionCountForPenalty

func (dm *DatabaseManager) SubmissionCountForPenalty(cid, iid, pid, sid int64, CEContained bool) (int64, error)

func (*DatabaseManager) SubmissionFind

func (dm *DatabaseManager) SubmissionFind(cid, sid int64) (*Submission, error)

func (*DatabaseManager) SubmissionGetCase

func (dm *DatabaseManager) SubmissionGetCase(cid, sid int64) ([]SubmissionTestCase, error)

func (*DatabaseManager) SubmissionGetCode

func (dm *DatabaseManager) SubmissionGetCode(cid, sid int64) (string, error)

func (*DatabaseManager) SubmissionGetMsg

func (dm *DatabaseManager) SubmissionGetMsg(cid, sid int64) (string, error)

func (*DatabaseManager) SubmissionListWithPid

func (dm *DatabaseManager) SubmissionListWithPid(cid, pid int64) ([]Submission, error)

func (*DatabaseManager) SubmissionMaximumScore

func (dm *DatabaseManager) SubmissionMaximumScore(cid, iid, pid int64) (*Submission, error)

func (*DatabaseManager) SubmissionRemove

func (dm *DatabaseManager) SubmissionRemove(cid, sid int64) error

func (*DatabaseManager) SubmissionRemoveAllWithTable

func (dm *DatabaseManager) SubmissionRemoveAllWithTable(cid int64) error

func (*DatabaseManager) SubmissionRemoveForProblem

func (dm *DatabaseManager) SubmissionRemoveForProblem(cid, pid int64) error

func (*DatabaseManager) SubmissionSetMsg

func (dm *DatabaseManager) SubmissionSetMsg(cid, sid int64, msg string) error

func (*DatabaseManager) SubmissionTestCaseDeleteUnassociated

func (dm *DatabaseManager) SubmissionTestCaseDeleteUnassociated(cid int64) error

func (*DatabaseManager) SubmissionUpdate

func (dm *DatabaseManager) SubmissionUpdate(cid, sid, time, mem int64, status sctypes.SubmissionStatusType, fin, all int64, score int64) (ret error)

func (*DatabaseManager) SubmissionUpdateResult

func (dm *DatabaseManager) SubmissionUpdateResult(cid, sid, jid int64, status sctypes.SubmissionStatusType, score, time, mem int64, message io.Reader) error

func (*DatabaseManager) SubmissionUpdateTestCase

func (dm *DatabaseManager) SubmissionUpdateTestCase(cid, sid, jid int64, status string, res SubmissionTestCase) error

func (*DatabaseManager) SubmissionUsedJidPlusOne

func (dm *DatabaseManager) SubmissionUsedJidPlusOne(cid, sid int64) error

func (*DatabaseManager) SubmissionViewCount

func (dm *DatabaseManager) SubmissionViewCount(cid, iid, lid, pidx, stat int64) (int64, error)

func (*DatabaseManager) SubmissionViewFind

func (dm *DatabaseManager) SubmissionViewFind(sid, cid int64) (*SubmissionView, error)

func (*DatabaseManager) SubmissionViewList

func (dm *DatabaseManager) SubmissionViewList(cid, iid, lid, pidx, stat, offset, limit int64) ([]SubmissionView, error)

func (*DatabaseManager) UserAdd

func (dm *DatabaseManager) UserAdd(uid string, userName string, pass string, email sql.NullString, gid int64, enabled bool) (int64, error)

UserAdd adds a new user

func (*DatabaseManager) UserCount

func (dm *DatabaseManager) UserCount() (int64, error)

func (*DatabaseManager) UserFindFromIID

func (dm *DatabaseManager) UserFindFromIID(iid int64) (*User, error)

UserFindFromIID finds an User with iid

func (*DatabaseManager) UserFindFromUserID

func (dm *DatabaseManager) UserFindFromUserID(uid string) (*User, error)

UserFindFromUserID finds an User with Uid

func (*DatabaseManager) UserList

func (dm *DatabaseManager) UserList(limit, offset int64) ([]User, error)

func (*DatabaseManager) UserUpdate

func (dm *DatabaseManager) UserUpdate(iid int64, uid string, userName string, pass string, email string, gid int64, enabled bool) error

UserUpdate updates the user with iid

func (*DatabaseManager) UserUpdateEnabled

func (dm *DatabaseManager) UserUpdateEnabled(iid int64, enabled bool) error

func (*DatabaseManager) UserUpdatePassword

func (dm *DatabaseManager) UserUpdatePassword(iid int64, pass string) error

type Group

type Group struct {
	Gid  int64  `gorm:"primary_key"`
	Name string `gorm:"not null;unique_index"`
}

Group is a struct to save GroupData

type Language

type Language struct {
	Lid           int64  `gorm:"primary_key"`
	Name          string `gorm:"not null"`
	HighlightType string `gorm:"not null"`
	Active        bool   `gorm:"not null;default:true;index"`
}

type News

type News struct {
	Nid      int64     `gorm:"primary_key"`
	Text     string    `gorm:"size:4095"`
	UnixTime time.Time `gorm:"not null;index"`
}

"create table if not exists news (text varchar(256), unixTime int, index uti(unixTime))" News contains news showed on "/"

type Session

type Session struct {
	SessionKey string `gorm:"primary_key;size:50"`
	Iid        int64  `gorm:"not null;index"`
	TimeLimit  int64  `gorm:"not null;index"`
}

SessionTemplateData contains data in SQL DB "create table if not exists sessions (sessionKey varchar(50) primary key, internalID int(11), unixTimeLimit int(11), index iid(internalID), index idx(unixTimeLimit))"

type SessionTemplateData

type SessionTemplateData struct {
	Iid      int64
	UserID   string
	UserName string
	Gid      int64
}

type SqlScanIgnore

type SqlScanIgnore struct{}

func (*SqlScanIgnore) Scan

func (rc *SqlScanIgnore) Scan(v interface{}) error

type Submission

type Submission struct {
	Cid         int64                        `gorm:"-"`
	Sid         int64                        `gorm:"primary_key"`
	Pid         int64                        `gorm:"not null;index"`     //index
	Iid         int64                        `gorm:"not null;index"`     //index
	Jid         int64                        `gorm:"not null"`           // jid for status, time, mem etc...
	UsedJid     int64                        `gorm:"not null";default:0` // jid for judge
	Lang        int64                        `gorm:"not null"`
	Time        int64                        `gorm:"not null"` //ms
	Mem         int64                        `gorm:"not null"` //KB
	Score       int64                        `gorm:"not null"`
	SubmitTime  time.Time                    `gorm:"not null;default:CURRENT_TIMESTAMP"` //提出日時
	Status      sctypes.SubmissionStatusType `gorm:"not null;index"`                     //index
	MessageFile string                       `gorm:"not null"`
	CodeFile    string                       `gorm:"not null"`
	Cases       []SubmissionTestCase         `gorm:"ForeignKey:Sid"`
}

func (Submission) TableName

func (s Submission) TableName() string

type SubmissionTestCase

type SubmissionTestCase struct {
	ID     int64 `gorm:"primary_key"`
	Sid    int64 `gorm:"index"`
	Cid    int64 `gorm:"-"`
	Status sctypes.SubmissionStatusType
	CaseID int64
	Name   string
	Time   int64
	Mem    int64
}

func (SubmissionTestCase) TableName

func (stc SubmissionTestCase) TableName() string

type SubmissionView

type SubmissionView struct {
	SubmitTime    time.Time
	Cid           int64
	Pidx          int64
	Name          string
	Uid           string
	UserName      string
	Lang          string
	Score         int64
	RawStatus     sctypes.SubmissionStatusType `gorm:"column:status"`
	Time          int64
	Mem           int64
	Sid           int64
	HighlightType string
	Iid           int64
	Status        string `gorm:"-"`
}

type User

type User struct {
	Iid      int64          `gorm:"primary_key"`
	Uid      string         `gorm:"not null;size:128;unique_index"`
	UserName string         `gorm:"not null;size:256;unique_index"`
	PassHash []byte         `gorm:"not null"`
	Email    sql.NullString `gorm:"size:128;unique_index"`
	Gid      int64
	Enabled  bool `gorm:"not null;default:true"`
}

User is a struct to save UserData

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL