From 80ee46c81dda5331f66aa401435447f22ff187cd Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 21 Mar 2025 09:23:01 +0900 Subject: feat(frontend): show game result in 1v1 watch --- backend/api/handler.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'backend/api/handler.go') 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 { -- cgit v1.2.3-70-g09d2