diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-11 01:23:41 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-11 01:23:41 +0900 |
| commit | a93c441ec4f992ed2f7eeae23fb823b1d152913f (patch) | |
| tree | c8e7750019849a7100d11ac6b81517ad0d5c98ea /backend/api/handler.go | |
| parent | 57212d2c7992a46827f503ae70c8e31f2084b718 (diff) | |
| download | phperkaigi-2025-albatross-a93c441ec4f992ed2f7eeae23fb823b1d152913f.tar.gz phperkaigi-2025-albatross-a93c441ec4f992ed2f7eeae23fb823b1d152913f.tar.zst phperkaigi-2025-albatross-a93c441ec4f992ed2f7eeae23fb823b1d152913f.zip | |
feat: show user label
Diffstat (limited to 'backend/api/handler.go')
| -rw-r--r-- | backend/api/handler.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/backend/api/handler.go b/backend/api/handler.go index 4896a28..8d04693 100644 --- a/backend/api/handler.go +++ b/backend/api/handler.go @@ -101,12 +101,19 @@ func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, _ *auth for _, row := range mainPlayerRows { idx := gameID2Index[row.GameID] game := &games[idx] + var label nullable.Nullable[string] + if row.Label != nil { + label = nullable.NewNullableWithValue(*row.Label) + } else { + label = nullable.NewNullNullable[string]() + } game.MainPlayers = append(game.MainPlayers, User{ UserID: int(row.UserID), Username: row.Username, DisplayName: row.DisplayName, IconPath: row.IconPath, IsAdmin: row.IsAdmin, + Label: label, }) } return GetGames200JSONResponse{ @@ -145,12 +152,19 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, _ * } mainPlayers := make([]User, len(mainPlayerRows)) for i, playerRow := range mainPlayerRows { + var label nullable.Nullable[string] + if playerRow.Label != nil { + label = nullable.NewNullableWithValue(*playerRow.Label) + } else { + label = nullable.NewNullNullable[string]() + } mainPlayers[i] = User{ UserID: int(playerRow.UserID), Username: playerRow.Username, DisplayName: playerRow.DisplayName, IconPath: playerRow.IconPath, IsAdmin: playerRow.IsAdmin, + Label: label, } } game := Game{ @@ -260,6 +274,12 @@ func (h *Handler) GetGameWatchRanking(ctx context.Context, request GetGameWatchR } ranking := make([]RankingEntry, len(rows)) for i, row := range rows { + var label nullable.Nullable[string] + if row.Label != nil { + label = nullable.NewNullableWithValue(*row.Label) + } else { + label = nullable.NewNullNullable[string]() + } ranking[i] = RankingEntry{ Player: User{ UserID: int(row.UserID), @@ -267,6 +287,7 @@ func (h *Handler) GetGameWatchRanking(ctx context.Context, request GetGameWatchR DisplayName: row.DisplayName, IconPath: row.IconPath, IsAdmin: row.IsAdmin, + Label: label, }, Score: int(row.CodeSize), } |
