Skip to content

Commit 31b7e7a

Browse files
committed
fixes
1 parent bf1fdd4 commit 31b7e7a

File tree

8 files changed

+953
-369
lines changed

8 files changed

+953
-369
lines changed

common/db/models/problem.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ type TestGroup struct {
4949
// TestScore meaningful only in case of TestGroupScoringTypeEachTest
5050
TestScore *float64 `json:"test_score" yaml:"test_score"`
5151
// Score meaningful only in case of TestGroupScoringTypeComplete
52-
Score *float64 `json:"score" yaml:"score"`
53-
ScoringType TestGroupScoringType `json:"scoring_type" yaml:"scoring_type"`
54-
FeedbackType TestGroupFeedbackType `json:"feedback_type" yaml:"feedback_type"`
55-
RequiredGroups []string `json:"required_groups" yaml:"required_groups"`
52+
Score *float64 `json:"score" yaml:"score"`
53+
ScoringType TestGroupScoringType `json:"scoring_type" yaml:"scoring_type"`
54+
FeedbackType TestGroupFeedbackType `json:"feedback_type" yaml:"feedback_type"`
55+
RequiredGroupNames []string `json:"required_groups" yaml:"required_groups"`
5656
}
5757

5858
func (t TestGroup) Value() (driver.Value, error) {
@@ -81,14 +81,14 @@ type Problem struct {
8181
gorm.Model
8282

8383
ProblemType ProblemType
84-
// TestGroups ignored for ICPC problems
85-
TestGroups []TestGroup
8684

8785
TimeLimit customfields.Time
8886
MemoryLimit customfields.Memory
8987
WallTimeLimit *customfields.Time
9088

9189
TestsNumber uint64
90+
// TestGroups ignored for ICPC problems
91+
TestGroups []TestGroup
9292

9393
MaxOpenFiles *uint64
9494
MaxThreads *uint64

common/db/models/submission.go

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import (
1111
)
1212

1313
type 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

2122
type 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+
4577
type 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
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package jobgenerators
2+
3+
// used in IOI and ICPC generators
4+
type generatorState int
5+
6+
const (
7+
compilationNotStarted generatorState = iota
8+
compilationStarted
9+
compilationFinished
10+
)

0 commit comments

Comments
 (0)