aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/api/handler.go')
-rw-r--r--backend/api/handler.go38
1 files changed, 17 insertions, 21 deletions
diff --git a/backend/api/handler.go b/backend/api/handler.go
index e70f298..4150ba6 100644
--- a/backend/api/handler.go
+++ b/backend/api/handler.go
@@ -89,11 +89,6 @@ func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, user *a
startedAtTimestamp := int(row.StartedAt.Time.Unix())
startedAt = &startedAtTimestamp
}
- problem := &Problem{
- ProblemID: int(row.ProblemID),
- Title: row.Title,
- Description: row.Description,
- }
games[i] = Game{
GameID: int(row.GameID),
GameType: GameGameType(row.GameType),
@@ -101,7 +96,11 @@ func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, user *a
DisplayName: row.DisplayName,
DurationSeconds: int(row.DurationSeconds),
StartedAt: startedAt,
- Problem: problem,
+ Problem: Problem{
+ ProblemID: int(row.ProblemID),
+ Title: row.Title,
+ Description: row.Description,
+ },
}
}
return GetGames200JSONResponse{
@@ -111,6 +110,7 @@ func (h *Handler) GetGames(ctx context.Context, _ GetGamesRequestObject, user *a
func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, user *auth.JWTClaims) (GetGameResponseObject, error) {
// TODO: check user permission
+ _ = user
gameID := request.GameID
row, err := h.q.GetGameByID(ctx, int32(gameID))
if err != nil {
@@ -128,14 +128,6 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use
startedAtTimestamp := int(row.StartedAt.Time.Unix())
startedAt = &startedAtTimestamp
}
- var problem *Problem
- 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))
if err != nil {
return nil, echo.NewHTTPError(http.StatusInternalServerError, err.Error())
@@ -165,13 +157,17 @@ func (h *Handler) GetGame(ctx context.Context, request GetGameRequestObject, use
}
}
game := Game{
- GameID: int(row.GameID),
- GameType: GameGameType(row.GameType),
- State: GameState(row.State),
- DisplayName: row.DisplayName,
- DurationSeconds: int(row.DurationSeconds),
- StartedAt: startedAt,
- Problem: problem,
+ GameID: int(row.GameID),
+ GameType: GameGameType(row.GameType),
+ State: GameState(row.State),
+ DisplayName: row.DisplayName,
+ DurationSeconds: int(row.DurationSeconds),
+ StartedAt: startedAt,
+ Problem: Problem{
+ ProblemID: int(row.ProblemID),
+ Title: row.Title,
+ Description: row.Description,
+ },
Players: players,
VerificationSteps: verificationSteps,
}