diff options
Diffstat (limited to 'backend/api/handler.go')
| -rw-r--r-- | backend/api/handler.go | 21 |
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 { |
