aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-10 14:06:28 +0900
committernsfisis <nsfisis@gmail.com>2024-08-10 19:55:45 +0900
commit0b520dc2529d7df6263842480d4ba7eaf07f4dcd (patch)
tree4a015b17210ba1d61ca98d2e18e339c817016f8c /backend/api
parenta8f2594e8dcb741fb942092cbc53d64cf93132ef (diff)
downloadphperkaigi-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')
-rw-r--r--backend/api/generated.go51
-rw-r--r--backend/api/handler.go15
2 files changed, 41 insertions, 25 deletions
diff --git a/backend/api/generated.go b/backend/api/generated.go
index 33f1a78..2a113a4 100644
--- a/backend/api/generated.go
+++ b/backend/api/generated.go
@@ -65,6 +65,7 @@ type Game struct {
DurationSeconds int `json:"duration_seconds"`
GameID int `json:"game_id"`
GameType GameGameType `json:"game_type"`
+ Players []User `json:"players"`
Problem *Problem `json:"problem,omitempty"`
StartedAt *int `json:"started_at,omitempty"`
State GameState `json:"state"`
@@ -1108,31 +1109,31 @@ func (sh *strictHandler) GetToken(ctx echo.Context, params GetTokenParams) error
var swaggerSpec = []string{
"H4sIAAAAAAAC/9xZbW/bthP/KvrzP6AboPkpQdH5XZq1WYeuM+oWe1EEBi2dbWYSqZJUHC/Qdx9I6sGU",
- "KFt2laBYXgS2xLv73d2Pd2fyEQUsThgFKgWaPqIEcxyDBK6/bQCHwBc4lRvGyT9YEkbVc0LRNH+JfERx",
- "DGiKrqxVPuLwNSUcQjSVPAUfiWADMVbicpcoASE5oWuUZT5KsNws1jiGBQlLA+phpb5420ExoRLWwFGm",
- "VHMQCaMCtEOvcfgRvqYgpPoWMCqB6o84SSISaO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V0/zB0nwafNkR4RHjYK7oLVyEyQ52WgyQyqlW8HJXr6NLd4RieGU32Qa7LaX1I",
+ "eMIx6u9sQ71fGbg8JQGjC32tYIkMSYzXIIZ3bEMHd8naKSoWOIyJHd8VjkS1+JeMRYD1oXsqHOVlcuGK",
+ "qJra9EJBaY1nYWVPSeOEsMTdjK1SR+iK6QMHk1d0FS2x5EwIr/jC8Law9K5m75CP7oELc94+GowHI4We",
+ "JUBxQtAUXQxGgxEyVzk6RcM1jk2y1qCXg8qfPq18F6IpugF5oyf41qXTgYaomjJ0Xkplt7WbnslodNK1",
+ "g02vEnqnc2x90t84x3ac64oDWbAvM94TIT228oxE5qPL0fgQhNLnoX0FooQu2oX2borURpLGMea7AkJu",
+ "P/PzVA4f87PprC2pPeXUb5Wz7g2fgAPdMu/IdKdEX+kQP1uGlcRlu0R5YWhT4gakh3PAihIRW5tqmDDh",
+ "YMKMCfleTzHBASFfM3PUeWY+EizElvGw1m/nb8eTC1fZ5rAmQuaXJJL9DbUN8qH259LxjRWaFgsih+9m",
+ "hn2pnfXK5EN+D/b+t/dKWkkXWs9NS7tKo2jnKcoClQpqwdqTqW7xUPUDniGf5mHp3KGC9ElP+B53mf9U",
+ "Xkx9EBvG5c8RuYfQw9qcZwBmWZb9GwAA///7T0ccbSIAAA==",
}
// GetSwagger returns the content of the embedded swagger specification file
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,