diff --git a/cmd/omegaup-grader/frontend_handler.go b/cmd/omegaup-grader/frontend_handler.go index e719c47..3e1dba5 100644 --- a/cmd/omegaup-grader/frontend_handler.go +++ b/cmd/omegaup-grader/frontend_handler.go @@ -254,22 +254,22 @@ func broadcastRun( message.Contest = *run.Contest } type serializedRun struct { - User string `json:"username"` - Contest *string `json:"contest_alias,omitempty"` - Problemset *int64 `json:"problemset,omitempty"` - Problem string `json:"alias"` - GUID string `json:"guid"` - Runtime float64 `json:"runtime"` - Penalty float64 `json:"penalty"` - Memory base.Byte `json:"memory"` - Score float64 `json:"score"` - ContestScore float64 `json:"contest_score"` - Status string `json:"status"` - Verdict string `json:"verdict"` - SubmitDelay float64 `json:"submit_delay"` - Time float64 `json:"time"` - Language string `json:"language"` - ScorePerGroup map[string]float64 `json:"score_per_group"` + User string `json:"username"` + Contest *string `json:"contest_alias,omitempty"` + Problemset *int64 `json:"problemset,omitempty"` + Problem string `json:"alias"` + GUID string `json:"guid"` + Runtime float64 `json:"runtime"` + Penalty float64 `json:"penalty"` + Memory base.Byte `json:"memory"` + Score float64 `json:"score"` + ContestScore float64 `json:"contest_score"` + Status string `json:"status"` + Verdict string `json:"verdict"` + SubmitDelay float64 `json:"submit_delay"` + Time float64 `json:"time"` + Language string `json:"language"` + ScoreByGroup map[string]float64 `json:"score_by_group"` } type runFinishedMessage struct { Message string `json:"message"` @@ -284,21 +284,21 @@ func broadcastRun( msg := runFinishedMessage{ Message: "/run/update/", Run: serializedRun{ - Contest: run.Contest, - Problemset: run.Problemset, - Problem: run.Run.ProblemName, - GUID: run.GUID, - Runtime: run.Result.Time, - Memory: run.Result.Memory, - Score: score, - ContestScore: contestScore, - Status: "ready", - Verdict: run.Result.Verdict, - Language: run.Run.Language, - Time: -1, - SubmitDelay: -1, - Penalty: -1, - ScorePerGroup: make(map[string]float64), + Contest: run.Contest, + Problemset: run.Problemset, + Problem: run.Run.ProblemName, + GUID: run.GUID, + Runtime: run.Result.Time, + Memory: run.Result.Memory, + Score: score, + ContestScore: contestScore, + Status: "ready", + Verdict: run.Result.Verdict, + Language: run.Run.Language, + Time: -1, + SubmitDelay: -1, + Penalty: -1, + ScoreByGroup: make(map[string]float64), }, } var runTime time.Time @@ -337,14 +337,14 @@ func broadcastRun( scores := make(map[string]float64) for rows.Next() { var groupName string - var scoreByGroup float64 - err = rows.Scan(&groupName, &scoreByGroup) + var scorePerGroup float64 + err = rows.Scan(&groupName, &scorePerGroup) if err != nil { return fmt.Errorf("failed to scan run group: %w", err) } - scores[groupName] = scoreByGroup + scores[groupName] = scorePerGroup } - msg.Run.ScorePerGroup = scores + msg.Run.ScoreByGroup = scores msg.Run.Time = float64(runTime.Unix()) message.User = msg.Run.User if run.Problemset != nil { diff --git a/cmd/omegaup-grader/frontend_handler_test.go b/cmd/omegaup-grader/frontend_handler_test.go index 9c1127e..88da0a8 100644 --- a/cmd/omegaup-grader/frontend_handler_test.go +++ b/cmd/omegaup-grader/frontend_handler_test.go @@ -357,14 +357,14 @@ func TestBroadcastRun(t *testing.T) { verdict string score *big.Rat expectedScore float64 - scorePerGroup map[string]any + scoreByGroup map[string]any }{ { scoreMode: "partial", verdict: "AC", score: big.NewRat(1, 1), expectedScore: 1., - scorePerGroup: map[string]any{ + scoreByGroup: map[string]any{ "easy": 0.1, "medium": 0.2, "sample": 0.3, @@ -375,7 +375,7 @@ func TestBroadcastRun(t *testing.T) { verdict: "PA", score: big.NewRat(1, 2), expectedScore: 0.5, - scorePerGroup: map[string]any{ + scoreByGroup: map[string]any{ "easy": 0.1, "medium": 0.2, "sample": 0.3, @@ -386,7 +386,7 @@ func TestBroadcastRun(t *testing.T) { verdict: "PA", score: big.NewRat(1, 2), expectedScore: 0., - scorePerGroup: map[string]any{ + scoreByGroup: map[string]any{ "easy": 0.1, "medium": 0.2, "sample": 0.3, @@ -397,7 +397,7 @@ func TestBroadcastRun(t *testing.T) { verdict: "PA", score: big.NewRat(1, 3), expectedScore: 0.3333333333333333, - scorePerGroup: map[string]any{ + scoreByGroup: map[string]any{ "easy": 0.1, "medium": 0.2, "sample": 0.3, @@ -452,10 +452,10 @@ func TestBroadcastRun(t *testing.T) { t.Fatalf("Message does not contain a run entry: %v", encodedMessage) } - if !reflect.DeepEqual(s.scorePerGroup, runInfo["score_per_group"]) { - t.Errorf("message.score_per_group=%v (type %T), want %v (type %T)", - runInfo["score_per_group"], runInfo["score_per_group"], - s.scorePerGroup, s.scorePerGroup) + if !reflect.DeepEqual(s.scoreByGroup, runInfo["score_by_group"]) { + t.Errorf("message.score_by_group=%v (type %T), want %v (type %T)", + runInfo["score_by_group"], runInfo["score_by_group"], + s.scoreByGroup, s.scoreByGroup) } for key, value := range map[string]any{