Skip to content

Commit

Permalink
Renamed the key score_per_group with score_by_group (#125)
Browse files Browse the repository at this point in the history
Fixing a key in order to match the name with the frontend key
  • Loading branch information
pabo99 authored Jun 11, 2023
1 parent 7d6432d commit 2fd1cb9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
70 changes: 35 additions & 35 deletions cmd/omegaup-grader/frontend_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions cmd/omegaup-grader/frontend_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 2fd1cb9

Please sign in to comment.