[Feat] 정상 도달 알림 페이로드 보강 및 정상까지 거리/시간 API 추가 - #398
Merged
Merged
Conversation
- TRACKING_SUMMIT_REACHED 에 milestoneIndex, milestoneDistanceM 추가 (FCM data + WebSocket) - TRACKING_PHOTO_MILESTONE FCM data 에 milestoneIndex 추가 - LiveActivityCourseResponse 에 summitDistance, summitEstimatedTime 추가 - 정상까지 거리 계산을 CourseSummitDistanceCalculator 로 분리 - evaluate() 주석 정정 — photo 4/4 와 summit 은 동시가 아니라 -10% / 정각으로 시차가 있음 정상 인증 사진 업로드 API 가 milestoneIndex, milestoneDistanceM 을 필수로 받는데 기존 SUMMIT_REACHED 는 빈 파라미터로 발송돼 프론트가 값을 꺼낼 수 없었다. 정상과 일치하는 마일스톤 인덱스는 정상 좌표가 있으면 3, 코스 절반을 정상으로 보는 fallback 코스는 1 이라 상수로 둘 수 없어 summitMark 에 가장 가까운 마일스톤으로 계산한다. 정상까지 거리 계산은 마일스톤과 Live Activity 응답이 같은 값을 써야 해서 (푸시 지점과 화면 표시가 어긋나면 안 됨) 별도 컴포넌트로 분리했다.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
📊 테스트 커버리지 리포트
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧾 요약
🔗 이슈
✨ 변경 내용
TRACKING_SUMMIT_REACHED에milestoneIndex,milestoneDistanceM추가 (FCM data + WebSocket 양쪽)TRACKING_PHOTO_MILESTONEFCM data 에milestoneIndex추가 (기존엔distance만 있었음)LiveActivityCourseResponse에summitDistance(m),summitEstimatedTime(분) 추가CourseSummitDistanceCalculator로 분리 — 마일스톤 계산과 Live Activity 응답이 같은 값을 써야 하기 때문evaluate()주석 정정 — photo 4/4 와 summit 은 동시가 아니라 -10% / 정각으로 시차가 있다CourseSummitDistanceCalculatorTest8건 포함)✅ 확인
📡 프론트 연동 계약
FCM data (모든 값이 문자열이다 —
AsyncNotificationDispatcher가String.valueOf로 넣는다)사진 업로드 API 는
Integer/Double을 받으므로 프론트에서 파싱이 필요하다.WebSocket
/topic/tracking/{sessionId}/summit(네이티브 타입 그대로){ "milestoneIndex": 3, "milestoneDistanceM": 2000.0, "halfwayMark": 2000.0, "reachedAt": "..." }halfwayMark는 이미 배포된 클라이언트 호환용으로 남겨둔 값이다. 신규 코드는milestoneDistanceM을 쓰면 된다.GET /api/tracking/live-activity/courses/{courseId}{ "totalDistance": 5000.0, "estimatedTime": 180, "summitDistance": 2000.0, "summitEstimatedTime": 72 }course.distance / 2대신summitDistance를 쓰면 푸시가 오는 지점과 정확히 일치한다.정상 좌표가 없어 계산 불가한 코스는 두 필드 모두 null 이라 프론트가 기존 방식으로 폴백하면 된다.
🔍 리뷰 포인트
1. 정상 마일스톤 인덱스는 상수가 아니다
summitMark == milestones[3]→ 3summitMark == course.distance/2 == milestones[1]→ 1하드코딩하면 fallback 코스에서 깨진다.
summitMark에 가장 가까운 마일스톤을 찾아 계산한다.두 경우를 각각 검증하는 테스트를 넣었다.
2. 정상까지 거리 계산을 별도 컴포넌트로 분리한 이유
마일스톤 푸시가 오는 지점과 화면에 표시되는 "정상까지 거리" 가 반드시 같은 값이어야 한다.
TrackingMilestoneCalculator의 private 메서드로 두면 Live Activity 응답이 같은 계산을 복제해야 해서어긋날 여지가 생긴다.
CourseSummitDistanceCalculator하나를 양쪽이 주입받게 했다.3.
summitEstimatedTime은 근사값이다duration × summitDistance / totalDistance비례배분이라 오르막이 평지보다 느리다는 점은 반영하지 못한다.정상을 코스 중간으로 가정하던 것보다는 실제에 가깝다. 비율은 1.0 으로 상한을 뒀다 —
정상까지 거리는 polyline Haversine 누적이고
course.distance는 출처가 달라 미세하게 넘길 수 있다.4.⚠️
/api/notifications/test동작 변경NotificationType.requiredKeys에 새 키를 넣어서, 이 두 타입을 파라미터 없이 테스트 발송하면이제
NOTIFICATION_PARAMS_INVALID가 난다. 계약을 발송 전에 강제하려는 의도된 동작이지만QA 에서 헷갈릴 수 있어 적어둔다.
📌 참고
±10% 윈도우 때문에 photo 4/4 OPEN 은 정상까지 거리의 90%, SUMMIT_REACHED 는 100% 지점이다(창은 110% 에서 닫힘).
SUMMIT_REACHED 도착 시점에 4/4 촬영 창이 열려 있는 것은 보장되지만, GPS 가 드물어 한 점이
±10% 구간을 통째로 건너뛰면 photo 4/4 는 발송되지 않고 정상 알림만 나간다.
→ 프론트는 정상 인증 UI 를 SUMMIT_REACHED 에 물리는 것이 안전하다.
develop 기준 baseline 과 동일하다. 이번 변경으로 인한 회귀는 없다.