[Feat] 등산 기록 응답에 트래킹 세션 ID를 추가#146
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 본 PR은 등산 기록 응답 데이터에 트래킹 세션 ID를 포함시켜, 클라이언트가 등산 기록에서 바로 관련 트래킹 사진 조회 API로 연결할 수 있도록 기능을 개선하였습니다. 이를 위해 데이터베이스 쿼리, DTO 매핑 로직, 그리고 관련 테스트 코드를 업데이트하였습니다. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
이번 PR은 데모 서비스에서 음수 count 요청 시 발생할 수 있는 인덱스 초과 오류를 방지하는 안전장치를 추가하고, 사용자 하이킹 기록 조회 시 세션 ID(sessionId)를 함께 반환하도록 DTO, Repository, Projection을 수정하며 관련 테스트 코드를 추가했습니다. 리뷰에서는 테스트 코드에서 인터페이스 기반 Projection을 모킹할 때 익명 클래스를 직접 구현하는 대신 Spring Data의 SpelAwareProxyProjectionFactory를 사용하여 보일러플레이트 코드를 줄이고 가독성을 높일 것을 제안했습니다.
| private UserHikingRecordProjection projection() { | ||
| return new UserHikingRecordProjection() { | ||
| @Override | ||
| public Long getHikingRecordId() { | ||
| return 1L; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getSessionId() { | ||
| return 10L; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getMountainId() { | ||
| return 2L; | ||
| } | ||
|
|
||
| @Override | ||
| public String getMountainName() { | ||
| return "관악산"; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getCourseId() { | ||
| return 3L; | ||
| } | ||
|
|
||
| @Override | ||
| public String getCourseName() { | ||
| return "연주대 코스"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getPhotoReportImageUrl() { | ||
| return "photo-report"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getCliveImageUrl() { | ||
| return "clive"; | ||
| } | ||
|
|
||
| @Override | ||
| public Double getDistance() { | ||
| return 6200.0; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getDuration() { | ||
| return 3600; | ||
| } | ||
|
|
||
| @Override | ||
| public LocalDateTime getHikedAt() { | ||
| return LocalDateTime.of(2026, 5, 28, 10, 0); | ||
| } | ||
| }; | ||
| } |
There was a problem hiding this comment.
테스트에서 인터페이스 기반의 Projection을 모킹하기 위해 익명 클래스를 직접 구현하는 방식은 코드가 매우 길어지고 유지보수하기 어렵습니다.
Spring Data에서 제공하는 SpelAwareProxyProjectionFactory를 사용하면 Map을 기반으로 Projection 프록시 객체를 간단하게 생성할 수 있습니다. 이를 통해 보일러플레이트 코드를 크게 줄이고 테스트 코드의 가독성을 높일 수 있습니다.
private UserHikingRecordProjection projection() {
org.springframework.data.projection.ProjectionFactory factory = new org.springframework.data.projection.SpelAwareProxyProjectionFactory();
return factory.createProjection(UserHikingRecordProjection.class, java.util.Map.ofEntries(
java.util.Map.entry("hikingRecordId", 1L),
java.util.Map.entry("sessionId", 10L),
java.util.Map.entry("mountainId", 2L),
java.util.Map.entry("mountainName", "관악산"),
java.util.Map.entry("courseId", 3L),
java.util.Map.entry("courseName", "연주대 코스"),
java.util.Map.entry("photoReportImageUrl", "photo-report"),
java.util.Map.entry("cliveImageUrl", "clive"),
java.util.Map.entry("distance", 6200.0),
java.util.Map.entry("duration", 3600),
java.util.Map.entry("hikedAt", LocalDateTime.of(2026, 5, 28, 10, 0))
));
}
🧾 요약
🔗 이슈
✨ 변경 내용
GetUserHikingRecordResponse에sessionId필드 추가UserHikingRecordProjection에sessionId조회 필드 추가hr.tracking_session_id AS sessionId반영sessionId매핑 추가GetUserHikingRecordResponse매핑 테스트 추가✅ 확인