aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/admin/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/admin/handler.go')
-rw-r--r--backend/admin/handler.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/backend/admin/handler.go b/backend/admin/handler.go
index 289a598..2a50cb0 100644
--- a/backend/admin/handler.go
+++ b/backend/admin/handler.go
@@ -542,6 +542,24 @@ func (h *Handler) postGameStart(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid game id")
}
+ game, err := h.q.GetGameByID(c.Request().Context(), int32(gameID))
+ if err != nil {
+ if errors.Is(err, pgx.ErrNoRows) {
+ return echo.NewHTTPError(http.StatusNotFound, "Game not found")
+ }
+ return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
+ }
+ testcases, err := h.q.ListTestcasesByProblemID(c.Request().Context(), game.ProblemID)
+ if err != nil {
+ if errors.Is(err, pgx.ErrNoRows) {
+ return echo.NewHTTPError(http.StatusBadRequest, "No testcases")
+ }
+ return echo.NewHTTPError(http.StatusInternalServerError, err.Error())
+ }
+ if len(testcases) == 0 {
+ return echo.NewHTTPError(http.StatusBadRequest, "No testcases")
+ }
+
startedAt := time.Now().Add(10 * time.Second)
err = h.q.UpdateGameStartedAt(c.Request().Context(), db.UpdateGameStartedAtParams{