aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handler.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-11 20:39:48 +0900
committernsfisis <nsfisis@gmail.com>2024-08-11 20:39:48 +0900
commit125e26b4d5c986f8531c098ecd5d291c1e1c7a76 (patch)
treefee5d641a05dc972a6b80fb3620d156f13d9b137 /backend/api/handler.go
parente3502d9e649fe61bb0ba4046b2c23c0d78bc92e9 (diff)
downloadphperkaigi-2025-albatross-125e26b4d5c986f8531c098ecd5d291c1e1c7a76.tar.gz
phperkaigi-2025-albatross-125e26b4d5c986f8531c098ecd5d291c1e1c7a76.tar.zst
phperkaigi-2025-albatross-125e26b4d5c986f8531c098ecd5d291c1e1c7a76.zip
feat(backend): make `games.problem_id` non-null
Diffstat (limited to 'backend/api/handler.go')
-rw-r--r--backend/api/handler.go29
1 files changed, 9 insertions, 20 deletions
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))