From 125e26b4d5c986f8531c098ecd5d291c1e1c7a76 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 11 Aug 2024 20:39:48 +0900 Subject: feat(backend): make `games.problem_id` non-null --- backend/api/handler.go | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'backend/api/handler.go') diff --git a/backend/api/handler.go b/backend/api/handler.go index 5b53791..e70f298 100644 --- a/backend/api/handler.go +++ b/backend/api/handler.go @@ -89,16 +89,10 @@ func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, user *a startedAtTimestamp := int(row.StartedAt.Time.Unix()) startedAt = &startedAtTimestamp } - var problem *Problem - if row.ProblemID != nil { - if row.Title == nil || row.Description == nil { - panic("inconsistent data") - } - problem = &Problem{ - ProblemID: int(*row.ProblemID), - Title: *row.Title, - Description: *row.Description, - } + problem := &Problem{ + ProblemID: int(row.ProblemID), + Title: row.Title, + Description: row.Description, } games[i] = Game{ GameID: int(row.GameID), @@ -135,16 +129,11 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID != nil { - if row.Title == nil || row.Description == nil { - panic("inconsistent data") - } - if user.IsAdmin || (GameState(row.State) != Closed && GameState(row.State) != WaitingEntries) { - problem = &Problem{ - ProblemID: int(*row.ProblemID), - Title: *row.Title, - Description: *row.Description, - } + if user.IsAdmin || (GameState(row.State) != Closed && GameState(row.State) != WaitingEntries) { + problem = &Problem{ + ProblemID: int(row.ProblemID), + Title: row.Title, + Description: row.Description, } } playerRows, err := h.q.ListGamePlayers(ctx, int32(gameID)) -- cgit v1.2.3-70-g09d2