[Feat] 라이브 액티비티 기능 추가#99
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds a live-activity course API that returns polyline coordinates, persists Course polylines, enforces one active tracking session per user via migration/index, centralizes session-save error translation, refines session response JSON, simplifies Redis stats reads, and adds developer documentation. ChangesLive Activity Course API and Session Robustness
Sequence Diagram(s)sequenceDiagram
participant Client
participant TrackingController
participant TrackingService
participant UserReader
participant CourseRepository
Client->>TrackingController: GET /api/tracking/live-activity/courses/{courseId}
TrackingController->>TrackingService: getLiveActivityCourse(userId, courseId)
TrackingService->>UserReader: findActiveUserById(userId)
UserReader-->>TrackingService: User (validated)
TrackingService->>CourseRepository: findById(courseId)
CourseRepository-->>TrackingService: Course (with polyline)
TrackingService->>TrackingService: LiveActivityCourseResponse.from(course)
Note over TrackingService: Validate polyline non-null/non-empty\nConvert LineString coordinates (y→lat, x→lon)
TrackingService-->>TrackingController: LiveActivityCourseResponse
TrackingController-->>Client: 200 OK (ApiResponse success)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CLAUDE.md`:
- Line 27: The fenced code blocks in CLAUDE.md are missing language identifiers
and trigger markdownlint MD040; update the two affected triple-backtick blocks
by adding "text" after the opening backticks so they become "```text" (i.e.,
replace the bare ``` used for the listing and for the branch-name examples),
ensuring both occurrences are updated to silence the lint warning and preserve
content formatting.
In
`@src/main/java/com/semosan/api/domain/tracking/controller/docs/TrackingControllerDocs.java`:
- Around line 47-68: The Swagger docs for getLiveActivityCourse in
TrackingControllerDocs are missing the 422 response for missing course polyline
(TRK_422_1); add an `@ApiResponse` entry with responseCode = "422", a descriptive
message (e.g., "코스 polyline 누락 - TRK_422_1"), and content = `@Content`(schema =
`@Schema`(implementation = ApiResponse.class)) alongside the existing 200 and 404
responses so the OpenAPI contract reflects the actual error case.
In
`@src/main/java/com/semosan/api/domain/tracking/service/TrackingSessionService.java`:
- Around line 152-157: The saveSession method in TrackingSessionService
currently maps every DataIntegrityViolationException from
trackingSessionRepository.save(session) to
ErrorStatus.TRACKING_SESSION_ALREADY_IN_PROGRESS; change this to only map the
specific unique/constraint violation that indicates "active session already
exists" (inspect the exception's rootCause message/constraint/index name against
the actual migration constraint name) and throw
GeneralException(ErrorStatus.TRACKING_SESSION_ALREADY_IN_PROGRESS) only in that
case, otherwise rethrow the original DataIntegrityViolationException or convert
to a more appropriate ErrorStatus so FK/NOT NULL and other integrity errors are
not misclassified.
In
`@src/main/resources/db/migration/V16__add_tracking_session_active_unique_index.sql`:
- Around line 3-5: The partial unique index creation
uq_tracking_sessions_user_active on table tracking_sessions (WHERE status IN
('IN_PROGRESS','PAUSED')) can fail if existing duplicate active sessions exist,
so add a preceding Flyway backfill migration that finds and resolves duplicates
before this migration runs: create a new migration that (1) identifies duplicate
rows by user_id with status IN ('IN_PROGRESS','PAUSED'), (2) deterministically
keeps one row per user (e.g., by earliest/ latest created_at or a chosen
business rule) and either deletes or marks others as non-active, and (3)
verifies no remaining duplicates, then keep the current V16 migration to create
uq_tracking_sessions_user_active; ensure the new migration runs earlier than V16
and includes safe, idempotent operations and audit logging as needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 53d0ac48-849e-4373-be21-624741faf728
📒 Files selected for processing (12)
CLAUDE.mdsrc/main/java/com/semosan/api/common/status/ErrorStatus.javasrc/main/java/com/semosan/api/common/status/SuccessStatus.javasrc/main/java/com/semosan/api/domain/mountain/entity/Course.javasrc/main/java/com/semosan/api/domain/tracking/controller/TrackingController.javasrc/main/java/com/semosan/api/domain/tracking/controller/docs/TrackingControllerDocs.javasrc/main/java/com/semosan/api/domain/tracking/dto/response/LiveActivityCourseResponse.javasrc/main/java/com/semosan/api/domain/tracking/dto/response/TrackingSessionResponse.javasrc/main/java/com/semosan/api/domain/tracking/service/TrackingService.javasrc/main/java/com/semosan/api/domain/tracking/service/TrackingSessionService.javasrc/main/java/com/semosan/api/domain/tracking/service/TrackingSessionStatsService.javasrc/main/resources/db/migration/V16__add_tracking_session_active_unique_index.sql
🧾 요약
courses.polyline데이터를 기반으로 좌표 배열을 응답하도록 구성🔗 이슈
✨ 변경 내용
GET /api/tracking/live-activity/courses/{courseId}API 추가Course.polyline을LineString으로 매핑하고, 응답 시{ latitude, longitude }배열로 변환polyline이 없거나 비어 있으면422 TRK_422_1에러 반환TRACKING_SESSION_ALREADY_IN_PROGRESS예외로 변환@JsonInclude(NON_NULL)적용 범위를hikingRecordId로 축소✅ 확인
./gradlew compileJava)Summary by CodeRabbit
New Features
Bug Fixes