JOJ3/internal/parser/resultstatus/parser.go
张泊明518370910136 ad549a4499
All checks were successful
submodules sync / sync (push) Successful in 39s
build / build (push) Successful in 2m10s
build / trigger-build-image (push) Successful in 12s
chore: only deps on go-judge/pb
2025-03-18 16:21:45 -04:00

37 lines
759 B
Go

package resultstatus
import (
"fmt"
"github.com/joint-online-judge/JOJ3/internal/stage"
)
func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {
conf, err := stage.DecodeConf[Conf](confAny)
if err != nil {
return nil, true, err
}
score := conf.Score
forceQuit := false
var res []stage.ParserResult
for _, result := range results {
comment := conf.Comment
if result.Status != stage.StatusAccepted {
score = 0
comment = fmt.Sprintf(
"Unexpected executor status: `%s`.\n", result.Status,
)
if conf.ForceQuitOnNotAccepted {
forceQuit = true
}
}
res = append(res, stage.ParserResult{
Score: score,
Comment: comment,
})
}
return res, forceQuit, nil
}