@@ -11,11 +11,12 @@ import (
1111)
1212
1313type TestResult struct {
14- TestNumber uint64 `json:"testNumber" yaml:"testNumber"`
15- Points * float64 `json:"points,omitempty" yaml:"points,omitempty"`
16- Verdict verdict.Verdict `json:"verdict" yaml:"verdict"`
17- Time customfields.Time `json:"time" yaml:"time"`
18- Memory customfields.Memory `json:"memory" yaml:"memory"`
14+ TestNumber uint64 `json:"TestNumber" yaml:"TestNumber"`
15+ Points * float64 `json:"Points,omitempty" yaml:"Points,omitempty"`
16+ Verdict verdict.Verdict `json:"Verdict" yaml:"Verdict"`
17+ Time customfields.Time `json:"Time" yaml:"Time"`
18+ Memory customfields.Memory `json:"Memory" yaml:"Memory"`
19+ Error string `json:"Error,omitempty" yaml:"Error,omitempty"`
1920}
2021
2122type TestResults []TestResult
@@ -42,12 +43,44 @@ func (t TestResults) GormDBDataType(db *gorm.DB, field *schema.Field) string {
4243 return ""
4344}
4445
46+ type GroupResult struct {
47+ GroupName string `json:"GroupName" yaml:"GroupName"`
48+ Points float64 `json:"Points" yaml:"Points"`
49+ Passed bool `json:"Passed" yaml:"Passed"`
50+ // TODO maybe more fields
51+ }
52+
53+ type GroupResults []GroupResult
54+
55+ func (t GroupResults ) Value () (driver.Value , error ) {
56+ return json .Marshal (t )
57+ }
58+
59+ func (t * GroupResults ) Scan (value interface {}) error {
60+ bytes , ok := value .([]byte )
61+ if ! ok {
62+ return errors .New ("type assertion to []byte failed" )
63+ }
64+ return json .Unmarshal (bytes , t )
65+ }
66+
67+ func (t GroupResults ) GormDBDataType (db * gorm.DB , field * schema.Field ) string {
68+ switch db .Dialector .Name () {
69+ case "mysql" , "sqlite" :
70+ return "JSON"
71+ case "postgres" :
72+ return "JSONB"
73+ }
74+ return ""
75+ }
76+
4577type Submission struct {
4678 gorm.Model
4779 ProblemID uint64
4880 Language string
4981
50- Score float64
51- Verdict verdict.Verdict
52- TestResults TestResults
82+ Score float64
83+ Verdict verdict.Verdict
84+ TestResults TestResults
85+ GroupResults GroupResults
5386}
0 commit comments