diff options
Diffstat (limited to 'backend/api/handlers.go')
| -rw-r--r-- | backend/api/handlers.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/backend/api/handlers.go b/backend/api/handlers.go index 91cdbc8..cd8b3b5 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -73,14 +73,14 @@ func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID.Valid { - if !row.Title.Valid || !row.Description.Valid { + if row.ProblemID != nil { + if row.Title == nil || row.Description == nil { panic("inconsistent data") } problem = &Problem{ - ProblemId: int(row.ProblemID.Int32), - Title: row.Title.String, - Description: row.Description.String, + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, } } games[i] = Game{ @@ -108,14 +108,14 @@ func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID.Valid { - if !row.Title.Valid || !row.Description.Valid { + if row.ProblemID != nil { + if row.Title == nil || row.Description == nil { panic("inconsistent data") } problem = &Problem{ - ProblemId: int(row.ProblemID.Int32), - Title: row.Title.String, - Description: row.Description.String, + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, } } games[i] = Game{ @@ -147,14 +147,14 @@ func (h *ApiHandler) GetGamesGameId(ctx context.Context, request GetGamesGameIdR startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID.Valid && GameState(row.State) != Closed && GameState(row.State) != WaitingEntries { - if !row.Title.Valid || !row.Description.Valid { + if row.ProblemID != nil && GameState(row.State) != Closed && GameState(row.State) != WaitingEntries { + if row.Title == nil || row.Description == nil { panic("inconsistent data") } problem = &Problem{ - ProblemId: int(row.ProblemID.Int32), - Title: row.Title.String, - Description: row.Description.String, + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, } } game := Game{ |
