diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-10 14:06:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-10 19:55:45 +0900 |
| commit | 0b520dc2529d7df6263842480d4ba7eaf07f4dcd (patch) | |
| tree | 4a015b17210ba1d61ca98d2e18e339c817016f8c /backend/api/handler.go | |
| parent | a8f2594e8dcb741fb942092cbc53d64cf93132ef (diff) | |
| download | phperkaigi-2025-albatross-0b520dc2529d7df6263842480d4ba7eaf07f4dcd.tar.gz phperkaigi-2025-albatross-0b520dc2529d7df6263842480d4ba7eaf07f4dcd.tar.zst phperkaigi-2025-albatross-0b520dc2529d7df6263842480d4ba7eaf07f4dcd.zip | |
feat(backend): include `players` in `Game` object
Diffstat (limited to 'backend/api/handler.go')
| -rw-r--r-- | backend/api/handler.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/backend/api/handler.go b/backend/api/handler.go index 23c3cfe..8830d1c 100644 --- a/backend/api/handler.go +++ b/backend/api/handler.go @@ -135,6 +135,20 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use } } } + playerRows, err := h.q.ListGamePlayers(ctx, int32(gameID)) + if err != nil { + return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + players := make([]User, len(playerRows)) + for i, playerRow := range playerRows { + players[i] = User{ + UserID: int(playerRow.UserID), + Username: playerRow.Username, + DisplayName: playerRow.DisplayName, + IconPath: playerRow.IconPath, + IsAdmin: playerRow.IsAdmin, + } + } game := Game{ GameID: int(row.GameID), GameType: GameGameType(row.GameType), @@ -143,6 +157,7 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use DurationSeconds: int(row.DurationSeconds), StartedAt: startedAt, Problem: problem, + Players: players, } return GetGame200JSONResponse{ Game: game, |
