aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-07 22:52:44 +0900
committernsfisis <nsfisis@gmail.com>2024-08-08 04:02:37 +0900
commit4295abfd48ad8ce217b251d07102deb8aee413d5 (patch)
treeb998f6f6c61a07760f5335e4aeeecf3893fd3758
parent5a2217f7a9d01b925c3db6491a363e6e4db9ca42 (diff)
downloadphperkaigi-2025-albatross-4295abfd48ad8ce217b251d07102deb8aee413d5.tar.gz
phperkaigi-2025-albatross-4295abfd48ad8ce217b251d07102deb8aee413d5.tar.zst
phperkaigi-2025-albatross-4295abfd48ad8ce217b251d07102deb8aee413d5.zip
refactor: rename task result's "result" to "status" for consistency
-rw-r--r--backend/game/hub.go2
-rw-r--r--backend/taskqueue/processor.go24
-rw-r--r--backend/taskqueue/tasks.go2
-rw-r--r--worker/exec.go8
-rw-r--r--worker/models.go6
5 files changed, 21 insertions, 21 deletions
diff --git a/backend/game/hub.go b/backend/game/hub.go
index ef69ddb..27a9847 100644
--- a/backend/game/hub.go
+++ b/backend/game/hub.go
@@ -209,7 +209,7 @@ func (hub *gameHub) processTaskResults() {
Type: playerMessageTypeS2CExecResult,
Data: playerMessageS2CExecResultPayload{
Score: nil,
- Status: api.GamePlayerMessageS2CExecResultPayloadStatus(taskResult.Result),
+ Status: api.GamePlayerMessageS2CExecResultPayloadStatus(taskResult.Status),
},
}
}
diff --git a/backend/taskqueue/processor.go b/backend/taskqueue/processor.go
index f789e2e..135a7d2 100644
--- a/backend/taskqueue/processor.go
+++ b/backend/taskqueue/processor.go
@@ -49,7 +49,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
Code string `json:"code"`
}
type swiftcResponseData struct {
- Result string `json:"result"`
+ Status string `json:"status"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
@@ -69,7 +69,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
if err := json.NewDecoder(res.Body).Decode(&resData); err != nil {
return fmt.Errorf("json.Decode failed: %v", err)
}
- if resData.Result != "success" {
+ if resData.Status != "success" {
err := p.q.CreateTestcaseResult(ctx, db.CreateTestcaseResultParams{
SubmissionID: submissionID,
TestcaseID: nil,
@@ -82,7 +82,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
}
p.results <- TaskExecResult{
Task: &payload,
- Result: "compile_error",
+ Status: "compile_error",
}
return fmt.Errorf("swiftc failed: %v", resData.Stderr)
}
@@ -93,7 +93,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
Code string `json:"code"`
}
type wasmcResponseData struct {
- Result string `json:"result"`
+ Status string `json:"status"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
@@ -113,7 +113,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
if err := json.NewDecoder(res.Body).Decode(&resData); err != nil {
return fmt.Errorf("json.Decode failed: %v", err)
}
- if resData.Result != "success" {
+ if resData.Status != "success" {
err := p.q.CreateTestcaseResult(ctx, db.CreateTestcaseResultParams{
SubmissionID: submissionID,
TestcaseID: nil,
@@ -126,7 +126,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
}
p.results <- TaskExecResult{
Task: &payload,
- Result: "compile_error",
+ Status: "compile_error",
}
return fmt.Errorf("wasmc failed: %v", resData.Stderr)
}
@@ -144,7 +144,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
Stdin string `json:"stdin"`
}
type testrunResponseData struct {
- Result string `json:"result"`
+ Status string `json:"status"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
@@ -165,11 +165,11 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
if err := json.NewDecoder(res.Body).Decode(&resData); err != nil {
return fmt.Errorf("json.Decode failed: %v", err)
}
- if resData.Result != "success" {
+ if resData.Status != "success" {
err := p.q.CreateTestcaseResult(ctx, db.CreateTestcaseResultParams{
SubmissionID: submissionID,
TestcaseID: testcase.TestcaseID,
- Status: resData.Result,
+ Status: resData.Status,
Stdout: resData.Stdout,
Stderr: resData.Stderr,
})
@@ -178,7 +178,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
}
p.results <- TaskExecResult{
Task: &payload,
- Result: resData.Result,
+ Status: resData.Status,
}
return fmt.Errorf("testrun failed: %v", resData.Stderr)
}
@@ -195,7 +195,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
}
p.results <- TaskExecResult{
Task: &payload,
- Result: "wrong_answer",
+ Status: "wrong_answer",
}
return fmt.Errorf("testrun failed: %v", resData.Stdout)
}
@@ -203,7 +203,7 @@ func (p *ExecProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
p.results <- TaskExecResult{
Task: &payload,
- Result: "success",
+ Status: "success",
}
return nil
}
diff --git a/backend/taskqueue/tasks.go b/backend/taskqueue/tasks.go
index db05553..5c518f4 100644
--- a/backend/taskqueue/tasks.go
+++ b/backend/taskqueue/tasks.go
@@ -30,7 +30,7 @@ func NewExecTask(gameID, userID int, code string) (*asynq.Task, error) {
type TaskExecResult struct {
Task *TaskExecPlayload
- Result string
+ Status string
Stdout string
Stderr string
}
diff --git a/worker/exec.go b/worker/exec.go
index 2ef16fa..10bc99a 100644
--- a/worker/exec.go
+++ b/worker/exec.go
@@ -95,7 +95,7 @@ func execSwiftCompile(
if err := os.WriteFile(inPath, []byte(code), 0644); err != nil {
return swiftCompileResponseData{
- Result: resultInternalError,
+ Status: resultInternalError,
Stdout: "",
Stderr: err.Error(),
}
@@ -116,7 +116,7 @@ func execSwiftCompile(
)
return swiftCompileResponseData{
- Result: convertCommandErrorToResultType(err),
+ Status: convertCommandErrorToResultType(err),
Stdout: stdout,
Stderr: stderr,
}
@@ -148,7 +148,7 @@ func execWasmCompile(
)
return wasmCompileResponseData{
- Result: convertCommandErrorToResultType(err),
+ Status: convertCommandErrorToResultType(err),
Stdout: stdout,
Stderr: stderr,
}
@@ -179,7 +179,7 @@ func execTestRun(
)
return testRunResponseData{
- Result: convertCommandErrorToResultType(err),
+ Status: convertCommandErrorToResultType(err),
Stdout: stdout,
Stderr: stderr,
}
diff --git a/worker/models.go b/worker/models.go
index b838fe0..a7310bd 100644
--- a/worker/models.go
+++ b/worker/models.go
@@ -33,7 +33,7 @@ func (req *swiftCompileRequestData) validate() error {
}
type swiftCompileResponseData struct {
- Result string `json:"result"`
+ Status string `json:"status"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
@@ -44,7 +44,7 @@ type wasmCompileRequestData struct {
}
type wasmCompileResponseData struct {
- Result string `json:"result"`
+ Status string `json:"status"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}
@@ -78,7 +78,7 @@ func (req *testRunRequestData) validate() error {
}
type testRunResponseData struct {
- Result string `json:"result"`
+ Status string `json:"status"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
}