aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/game
AgeCommit message (Collapse)Author
2026-03-20fix(game): allow participants to view watch states after game finishesnsfisis
Previously GetWatchLatestStates returned ErrForbidden for participants regardless of game state. Now checks whether the game has finished and permits access once complete. Also fixes config test env var cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-28fix(game): normalize CRLF to LF in stdin and code before executionnsfisis
DB stores stdin/code with CRLF intact, but workers expect LF. Add normalizeCRLF helper and apply it to code and stdin in EnqueueTestTasks. Refactor normalizeTestcaseResultOutput to reuse the same helper.
2026-02-28feat(admin): allow admin users to view and submit code before game startsnsfisis
Admin users can now access the gaming UI (problem description, code editor, submit button) even when a game has not started yet. Regular users still see the waiting screen as before. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21refactor: rename stuttering exported types in game and tournament packagesnsfisis
Fix golangci-lint revive warnings by removing package name prefixes: - game.GameHubInterface → game.HubInterface - game.GameDetail → game.Detail - tournament.TournamentEntry → tournament.Entry - tournament.TournamentMatch → tournament.Match - tournament.TournamentBracket → tournament.Bracket - tournament.TournamentEditData → tournament.EditData Also fix gofmt alignment in api/convert.go and gosimple S1016 in game/service.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21refactor(admin): separate business logic into game and tournament servicesnsfisis
Move transaction handling, rejudge workflow, tournament bracket creation, and data repair logic from admin handler into game.Service and tournament.Service, mirroring the earlier api package separation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21refactor(api): separate business logic into game, tournament, session packagesnsfisis
Extract business logic from api/handler.go into dedicated service packages: - session: context helpers (resolves admin → api import dependency) - game: game state, code submission, ranking, watch logic - tournament: bracket construction and seed ordering - api/convert.go: domain → API type conversion functions api/handler.go is now a thin adapter that delegates to services and maps domain errors to HTTP status codes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21perf(game): compile whitespace regex once at package levelnsfisis
Move regexp.MustCompile out of CalcCodeSize to avoid recompiling on every call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16test(backend): add unit tests for auth_middleware, fortee, processor, ↵nsfisis
account, and more handlers Cover previously untested code: SessionCookieMiddleware, context helpers, downloadFile, addAcceptHeader, doProcessTaskRunTestcase, updateSubmissionAndGameState, PostLogout, GetGames, PostGamePlayCode, GetGameWatchRanking, GetGameWatchLatestStates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16style(backend): fix lint errors in test filesnsfisis
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16test(backend): add unit tests for auth, config, ratelimit, game, and apinsfisis
Cover previously untested logic: session ID generation/hashing, password authentication, IP rate limiting, game state helpers, handler endpoints, task enqueue/result processing, and config loading. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15refactor(backend): introduce DI interfaces for testabilitynsfisis
Replace concrete *db.Queries and *pgxpool.Pool dependencies with db.Querier and db.TxManager interfaces across all handlers, game hub, and auth. This enables unit testing with mocks. - Enable sqlc emit_interface to generate Querier interface - Add TxManager abstraction to encapsulate transactions - Convert auth package-level functions to Authenticator struct - Add TaskQueueInterface/TaskWorkerInterface for game.Hub - Add initial unit tests for game logic and API handlers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15fix(backend): replace panic() with proper error handling in runtime codensfisis
auth/auth.go: return error instead of panicking on data inconsistency. game/hub.go: log unexpected task result types instead of panicking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15fix(backend): resolve TODO items for transactions, validation, and error ↵nsfisis
handling - Wrap multi-step DB operations in transactions (signup, submit, game edit, task result processing) - Add game running checks to PostGamePlayCode and PostGamePlaySubmit - Hide ranking code when game is not yet finished - Replace silenced errors in processTaskResults with slog.Error logging - Add pgxpool.Pool to Handler/Hub structs for transaction support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15refactor(log): migrate from log to log/slog for structured loggingnsfisis
Replace all usages of the standard log package with log/slog across backend and swift worker. Configure Echo's request logger to emit structured log attributes via slog instead of the default format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13refactor: rename module/package namensfisis
2025-09-06fix(backend): normalize line endings before comparing test resultsnsfisis
2025-09-05feat(worker-swift): compile and run in one requestnsfisis
2025-09-05feat(backend): support swift languagensfisis
2025-08-17feat: update "PHPerKaigi" to "iOSDC Japan"nsfisis
2025-03-08trim php tag before executionnsfisis
2025-03-08websocket to pollingnsfisis
2025-03-04update go package namesnsfisis
2024-08-18feat(backend): do now show error message except for compile errornsfisis
2024-08-18feat(backend): do now show success messagensfisis
2024-08-18refactor(backend): rename func name for consistencynsfisis
2024-08-12feat(backend): increase max WebSocket message size from 512 byte to 50 KiBnsfisis
2024-08-12feat: show left time in play pagensfisis
2024-08-12feat(backend): change calculation of code sizensfisis
2024-08-12refactor(backend): refactor sending `execresult` and `submitresult` messagesnsfisis
2024-08-12feat: add `submitresult` messagensfisis
2024-08-12feat: do not show preliminary scorensfisis
2024-08-11feat: simplify starting procedurensfisis
2024-08-11feat(backend): remove `prepare` message's payloadnsfisis
2024-08-11feat(backend): make `games.problem_id` non-nullnsfisis
2024-08-10feat: implement watch pagensfisis
2024-08-08feat(backend/worker): calculate code hash in api-servernsfisis
2024-08-08fix(backend): fix an issue where game type is not setnsfisis
2024-08-08feat(backend/worker): enable `revive` in `golangci-lint`nsfisis
2024-08-08feat(backend/woerker): enable `errcheck` in `golangci-lint`nsfisis
2024-08-08feat(backend/worker): enable `unused`, `gofmt` and `goimports` in ↵nsfisis
`golangci-lint`
2024-08-08feat(backend): aggregate testcase resultsnsfisis
2024-08-08feat(backend): implement processTaskResults() partiallynsfisis
2024-08-08refactor(backend): add Queue.Enqueue*() variantsnsfisis
2024-08-08feat(backend): split task into smaller task typesnsfisis
2024-08-08refactor: rename task result's "result" to "status" for consistencynsfisis
2024-08-08feat(backend): rename testcase_executions to testcase_resultsnsfisis
2024-08-08feat(backend): separate game hub worker channelnsfisis
* processing incoming WebSocket messages * processing task results
2024-08-08feat(backend): fix an issue where testcase execution results are sent to all ↵nsfisis
players
2024-08-08refactor(backend): move ownership of channel to send task resultsnsfisis
2024-08-05fix(backend): fix code submissionnsfisis