Conversation
|
There was also a suggestion to remove fields from the stack DB schema that are updated by the Container Provisioner, such as stack status, target port, ttl, node port, and public IP. However, we decided to keep them as-is, as the trade-offs introduced by refactoring were considered greater than the potential benefits. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Upon review, no additional tests are required. |
|
Additionally, the Handler-Service–Repository backend pattern has been further clarified through refactoring, and parts of the test code have also been refactored. |
|
PostgreSQL testcontainers(for Go) appear to be unstable. We will consider improving this in the future by adopting a different testing library or container library. |
There was a problem hiding this comment.
Pull request overview
This PR implements several refactoring improvements and bug fixes in preparation for the v1.1.0 release:
Changes:
- Introduced UserService and ScoreboardService layers to separate business logic from handlers
- Unified Redis cache keys (timeline:users, timeline:teams, leaderboard:users, leaderboard:teams) and removed window parameter from Timeline API
- Added comprehensive cache invalidation for username changes, team transfers, and challenge point updates
- Implemented skip-logging for sensitive endpoints (auth endpoints and challenge submissions)
- Changed file upload cleanup to best-effort (orphaned files acceptable if cleanup fails)
- Added ProvisionerMock for stack testing to replace inline test stubs
- Added UTC normalization in logging
- Added coverage check scripts
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/coverage_check/main.py | New coverage calculation script excluding specific files |
| scripts/coverage_check.sh | Bash wrapper for coverage check script |
| internal/stack/mock.go | New ProvisionerMock implementation for easier testing |
| internal/stack/mock_test.go | Tests for ProvisionerMock |
| internal/service/user_service.go | New UserService layer for user operations |
| internal/service/user_service_test.go | Tests for UserService |
| internal/service/scoreboard_service.go | New ScoreboardService layer with timeline aggregation |
| internal/service/scoreboard_service_test.go | Tests for ScoreboardService |
| internal/service/errors.go | Added service.ErrNotFound |
| internal/service/ctf_service.go | Changed file cleanup to best-effort |
| internal/service/ctf_service_test.go | Updated test to reflect new file cleanup behavior |
| internal/service/team_service.go | Updated to return service.ErrNotFound instead of repo.ErrNotFound |
| internal/service/team_service_test.go | Updated to use service.ErrNotFound |
| internal/service/testenv_test.go | Added new service instances to test environment |
| internal/service/stack_service_test.go | Refactored to use ProvisionerMock |
| internal/logging/logging.go | Added UTC normalization for time.Now() calls |
| internal/http/router.go | Updated to use UserService and ScoreboardService |
| internal/http/middleware/request_logger.go | Added sensitive path skipping and UTC normalization |
| internal/http/middleware/request_logger_test.go | Tests for sensitive path skipping |
| internal/http/handlers/handler.go | Major refactoring: service delegation, cache invalidation, timeline simplification |
| internal/http/handlers/handler_test.go | Tests for cache invalidation behavior |
| internal/http/handlers/testenv_test.go | Added new service instances to test environment |
| internal/http/handlers/errors.go | Updated to use service.ErrNotFound |
| internal/http/handlers/errors_test.go | Updated error mapping test |
| internal/http/integration/*.go | Updated to use ProvisionerMock and new services |
| docs/docs/scoreboard.md | Removed window parameter documentation |
| cmd/server/main.go | Wired up new services |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| `GET /api/timeline/teams` | ||
|
|
||
| Response 200 | ||
|
|
There was a problem hiding this comment.
The error section "Errors: - 400 invalid input" should be removed from the Team Timeline documentation since the window parameter was removed and there are no validation errors for this endpoint anymore.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The following refactoring and improvements have been made:
Fixed missing UTC normalization in the current time logic (
Now()).Skipped logging for endpoints that handle sensitive data, such as:
/api/auth/login/api/auth/register/api/auth/refresh/api/auth/logout/api/challenges/{id}/submitRemoved the
windowparameter from the Timeline API and optimized Redis cache key unification and invalidation. (Cache keys are now unified astimeline:users,timeline:teams,leaderboard:users,leaderboard:teams.)Previously, if deletion of the old file failed during file upload, the database had already been updated with the new key but still returned an error. We determined that orphaned files are acceptable in this case and updated the logic as follows:
Cache invalidation was missing in scenarios such as username changes, team transfers, and challenge point updates. This has now been addressed.
Additional refactoring may be added later and will be noted in the comments.