aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handler.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-03-21 09:23:01 +0900
committernsfisis <nsfisis@gmail.com>2025-03-21 09:50:56 +0900
commit80ee46c81dda5331f66aa401435447f22ff187cd (patch)
tree10830e1e882808b0ecbebd2164fd805160558ca2 /backend/api/handler.go
parentd379ce3309e5241359b9849fd0170909a140169c (diff)
downloadphperkaigi-2025-albatross-80ee46c81dda5331f66aa401435447f22ff187cd.tar.gz
phperkaigi-2025-albatross-80ee46c81dda5331f66aa401435447f22ff187cd.tar.zst
phperkaigi-2025-albatross-80ee46c81dda5331f66aa401435447f22ff187cd.zip
feat(frontend): show game result in 1v1 watch
Diffstat (limited to 'backend/api/handler.go')
-rw-r--r--backend/api/handler.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/backend/api/handler.go b/backend/api/handler.go
index 2cb04c5..04dbd5d 100644
--- a/backend/api/handler.go
+++ b/backend/api/handler.go
@@ -186,9 +186,10 @@ func (h *Handler) GetGamePlayLatestState(ctx context.Context, request GetGamePla
if errors.Is(err, pgx.ErrNoRows) {
return GetGamePlayLatestState200JSONResponse{
State: LatestGameState{
- Code: "",
- Score: nullable.NewNullNullable[int](),
- Status: None,
+ Code: "",
+ Score: nullable.NewNullNullable[int](),
+ BestScoreSubmittedAt: nullable.NewNullNullable[int64](),
+ Status: None,
},
}, nil
}
@@ -196,9 +197,10 @@ func (h *Handler) GetGamePlayLatestState(ctx context.Context, request GetGamePla
}
return GetGamePlayLatestState200JSONResponse{
State: LatestGameState{
- Code: row.Code,
- Score: toNullableWith(row.CodeSize, func(x int32) int { return int(x) }),
- Status: ExecutionStatus(row.Status),
+ Code: row.Code,
+ Score: toNullableWith(row.CodeSize, func(x int32) int { return int(x) }),
+ BestScoreSubmittedAt: nullable.NewNullableWithValue(row.CreatedAt.Time.Unix()),
+ Status: ExecutionStatus(row.Status),
},
}, nil
}
@@ -222,9 +224,10 @@ func (h *Handler) GetGameWatchLatestStates(ctx context.Context, request GetGameW
status = None
}
states[strconv.Itoa(int(row.UserID))] = LatestGameState{
- Code: code,
- Score: toNullableWith(row.CodeSize, func(x int32) int { return int(x) }),
- Status: status,
+ Code: code,
+ Score: toNullableWith(row.CodeSize, func(x int32) int { return int(x) }),
+ BestScoreSubmittedAt: nullable.NewNullableWithValue(row.CreatedAt.Time.Unix()),
+ Status: status,
}
if int(row.UserID) == user.UserID && !user.IsAdmin {