aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handlers.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-07-29 03:06:44 +0900
committernsfisis <nsfisis@gmail.com>2024-07-29 03:06:44 +0900
commit19b19e7f48d6375806f827713a98cffd2c57a434 (patch)
tree5b68e70a65a2434517c7e1ea5ea330fd686049d4 /backend/api/handlers.go
parentd1c8aa42aec32c8b042ae32d249df9c3c969453d (diff)
downloadiosdc-japan-2024-albatross-19b19e7f48d6375806f827713a98cffd2c57a434.tar.gz
iosdc-japan-2024-albatross-19b19e7f48d6375806f827713a98cffd2c57a434.tar.zst
iosdc-japan-2024-albatross-19b19e7f48d6375806f827713a98cffd2c57a434.zip
refactor(backend): enable emit_pointers_for_null_types in sqlc
Diffstat (limited to 'backend/api/handlers.go')
-rw-r--r--backend/api/handlers.go30
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{