From 175685c074eb64c5715d148fd1349bb76d695251 Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sun, 15 Sep 2024 08:26:33 -0400 Subject: [PATCH] feat: score & comment conf in result-status and dummy parser --- examples/diff/basic | 2 +- examples/diff/complex | 2 +- examples/healthcheck/asciimsg | 2 +- internal/parsers/dummy/parser.go | 3 ++- internal/parsers/resultstatus/parser.go | 12 +++++++----- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/diff/basic b/examples/diff/basic index af99032..4d0d2bf 160000 --- a/examples/diff/basic +++ b/examples/diff/basic @@ -1 +1 @@ -Subproject commit af990327ab095c22a383448ad70d915f8d10490b +Subproject commit 4d0d2bfdf8d2998f77b105d9d376ad52f3279fff diff --git a/examples/diff/complex b/examples/diff/complex index ac7a2fc..ce71d96 160000 --- a/examples/diff/complex +++ b/examples/diff/complex @@ -1 +1 @@ -Subproject commit ac7a2fc912fb51af156cd4babb7e72148ebe1c14 +Subproject commit ce71d96228ce42703278ff271356867994f6cb20 diff --git a/examples/healthcheck/asciimsg b/examples/healthcheck/asciimsg index 36bb5fb..d303867 160000 --- a/examples/healthcheck/asciimsg +++ b/examples/healthcheck/asciimsg @@ -1 +1 @@ -Subproject commit 36bb5fb15f100078bd3af1027017825932f8c24b +Subproject commit d303867e62383755b963fb7a519631106e82924e diff --git a/internal/parsers/dummy/parser.go b/internal/parsers/dummy/parser.go index da53cb2..02c3a08 100644 --- a/internal/parsers/dummy/parser.go +++ b/internal/parsers/dummy/parser.go @@ -5,6 +5,7 @@ import ( ) type Conf struct { + Score int Comment string } @@ -19,7 +20,7 @@ func (*Dummy) Run(results []stage.ExecutorResult, confAny any) ( } var res []stage.ParserResult for range results { - res = append(res, stage.ParserResult{Score: 0, Comment: conf.Comment}) + res = append(res, stage.ParserResult{Score: conf.Score, Comment: conf.Comment}) } return res, false, nil } diff --git a/internal/parsers/resultstatus/parser.go b/internal/parsers/resultstatus/parser.go index 3b1aad3..cb1774f 100644 --- a/internal/parsers/resultstatus/parser.go +++ b/internal/parsers/resultstatus/parser.go @@ -7,22 +7,24 @@ import ( "github.com/criyle/go-judge/envexec" ) -type Conf struct{} +type Conf struct { + Score int + Comment string +} type ResultStatus struct{} func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) ( []stage.ParserResult, bool, error, ) { - // TODO: more conf options - _, err := stage.DecodeConf[Conf](confAny) + conf, err := stage.DecodeConf[Conf](confAny) if err != nil { return nil, true, err } forceQuit := false var res []stage.ParserResult for _, result := range results { - comment := "" + comment := conf.Comment if result.Status != stage.Status(envexec.StatusAccepted) { forceQuit = true comment = fmt.Sprintf( @@ -30,7 +32,7 @@ func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) ( ) } res = append(res, stage.ParserResult{ - Score: 0, + Score: conf.Score, Comment: comment, }) }