diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-10 19:55:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-10 19:55:50 +0900 |
| commit | 47f95342097e8828059053c168e06cd44e0ab43b (patch) | |
| tree | 843d09397ccc1e5ec36c926e3eb555e1d6e5ed52 /backend/api/handler.go | |
| parent | 0b520dc2529d7df6263842480d4ba7eaf07f4dcd (diff) | |
| download | phperkaigi-2025-albatross-47f95342097e8828059053c168e06cd44e0ab43b.tar.gz phperkaigi-2025-albatross-47f95342097e8828059053c168e06cd44e0ab43b.tar.zst phperkaigi-2025-albatross-47f95342097e8828059053c168e06cd44e0ab43b.zip | |
feat(backend): include `verification_steps` in `Game` object
Diffstat (limited to 'backend/api/handler.go')
| -rw-r--r-- | backend/api/handler.go | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/backend/api/handler.go b/backend/api/handler.go index 8830d1c..134a4f9 100644 --- a/backend/api/handler.go +++ b/backend/api/handler.go @@ -3,11 +3,13 @@ package api import ( "context" "errors" + "fmt" "log" "net/http" "github.com/jackc/pgx/v5" "github.com/labstack/echo/v4" + "github.com/oapi-codegen/nullable" "github.com/nsfisis/iosdc-japan-2024-albatross/backend/auth" "github.com/nsfisis/iosdc-japan-2024-albatross/backend/db" @@ -149,15 +151,30 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use IsAdmin: playerRow.IsAdmin, } } + testcaseIDs, err := h.q.ListTestcaseIDsByGameID(ctx, int32(gameID)) + if err != nil { + return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + verificationSteps := make([]VerificationStep, len(testcaseIDs)+1) + verificationSteps[0] = VerificationStep{ + Label: "Compile", + } + for i, testcaseID := range testcaseIDs { + verificationSteps[i+1] = VerificationStep{ + TestcaseID: nullable.NewNullableWithValue(int(testcaseID)), + Label: fmt.Sprintf("Testcase %d", i+1), + } + } game := Game{ - GameID: int(row.GameID), - GameType: GameGameType(row.GameType), - State: GameState(row.State), - DisplayName: row.DisplayName, - DurationSeconds: int(row.DurationSeconds), - StartedAt: startedAt, - Problem: problem, - Players: players, + GameID: int(row.GameID), + GameType: GameGameType(row.GameType), + State: GameState(row.State), + DisplayName: row.DisplayName, + DurationSeconds: int(row.DurationSeconds), + StartedAt: startedAt, + Problem: problem, + Players: players, + VerificationSteps: verificationSteps, } return GetGame200JSONResponse{ Game: game, |
