Skip to content

feat: 등산 기록 단건 상세 조회 API + 칼로리 계산#160

Merged
JangInho merged 2 commits into
developfrom
feat/#155-hiking-record-detail
May 29, 2026
Merged

feat: 등산 기록 단건 상세 조회 API + 칼로리 계산#160
JangInho merged 2 commits into
developfrom
feat/#155-hiking-record-detail

Conversation

@JangInho

Copy link
Copy Markdown
Contributor

🧾 요약

  • 등산 기록 단건 상세 조회 API 개발

🔗 이슈

✨ 변경 내용

  • GET /api/hiking-records/{hikingRecordId} 추가
  • 본인이 참여한 등산 기록의 메타(코스/거리/소요시간/고도/칼로리) 와 함께 PostGIS 의 tracking_points 를 GeoJSON LineString + 점별 고도 배열로 묶고 마일스톤 사진 마커도 함께 반환
  • 칼로리는 사용자 체중 + 코스 강도(ascent/distance) 기반 MET 공식으로 HikingRecord.fromTrackingSession 시점에 1회 계산해 저장
  • 체중 미등록 시 65kg 기본값으로 대체 (정책적으로 결정 필요)

✅ 확인

  • 빌드 OK
  • 테스트 OK

GET /api/hiking-records/{hikingRecordId} 추가. 본인이 참여한 등산 기록의
메타(코스/거리/소요시간/고도/칼로리) 와 함께 PostGIS 의 tracking_points 를
GeoJSON LineString + 점별 고도 배열로 묶고 마일스톤 사진 마커도 함께 반환.

칼로리는 사용자 체중 + 코스 강도(ascent/distance) 기반 MET 공식으로
HikingRecord.fromTrackingSession 시점에 1회 계산해 저장.
체중 미등록 시 65kg 기본값으로 대체.
@JangInho JangInho self-assigned this May 29, 2026
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 95c3d3a3-09e8-4ef9-803d-e9c1f4e5a641

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#155-hiking-record-detail

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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!

This pull request introduces a detailed view for individual hiking records, providing users with comprehensive insights into their hiking activities. It includes the necessary API infrastructure, data projection, and a new calorie estimation feature to enrich the recorded hiking data.

Highlights

  • API Endpoint Addition: Added a new GET /api/hiking-records/{hikingRecordId} endpoint to retrieve detailed information for a specific hiking record.
  • Calorie Calculation Logic: Implemented a CalorieCalculator service using MET (Metabolic Equivalent of Task) formulas based on user weight, distance, and ascent, with a default weight of 65kg if not provided.
  • Data Retrieval Enhancements: Integrated PostGIS native queries to fetch tracking paths as GeoJSON LineStrings and altitude arrays, alongside associated milestone photos.
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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new API endpoint for retrieving detailed hiking records, including GPS tracks, altitudes, and milestone photos, and implements a calorie calculation utility (CalorieCalculator) based on MET values. The code review feedback suggests optimizing the HikingRecord retrieval with a join fetch query to prevent potential N+1 lazy loading issues when accessing related Mountain and Course entities. Additionally, it recommends adding unit tests for the new calorie calculation logic and the detail retrieval API to cover edge cases.

Comment thread src/main/java/com/semosan/api/domain/hiking/service/HikingRecordService.java Outdated
Comment on lines +27 to +31
public static int calculate(
Double weightKg,
Double distanceMeters,
Double ascentMeters,
int durationSeconds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[P2] 새롭게 추가된 칼로리 계산 로직(CalorieCalculator)과 등산 기록 상세 조회 API에 대한 단위 테스트가 누락되어 있습니다.\n\n### 이유\n칼로리 계산 공식(CalorieCalculator.calculate)은 체중 유무, 등산 강도(MET) 분기 등 다양한 경계 조건(Edge Case)을 포함하고 있으므로, 비즈니스 로직의 정확성을 보장하고 향후 변경 시 오작동을 방지하기 위해 철저한 단위 테스트가 필요합니다.\n\n### 해결 방안\nCalorieCalculatorTest를 추가하여 다음과 같은 시나리오들을 검증하는 테스트 코드를 작성하는 것을 권장합니다:\n- 체중이 없는 경우 기본 체중(65kg)으로 계산되는지 여부\n- 소요 시간이 0 이하일 때 0을 반환하는지 여부\n- 누적 상승고도와 거리 비율에 따라 MET 강도(EASY, MEDIUM, HARD)가 올바르게 판별되는지 여부

- HikingRecord 단건 상세 조회 시 Mountain/Course 를 fetch join 으로 함께
  가져와 응답 조립 단계의 LAZY 추가 SELECT 2건을 제거.
- 칼로리 기본 체중(65kg) 대체 정책에 향후 개선 방향(성별·나이 추정,
  온보딩 단계 입력 강제) TODO 주석 추가.
@JangInho
JangInho merged commit 74bfb76 into develop May 29, 2026
1 check passed
@howooyeon

Copy link
Copy Markdown
Contributor

우와오

@howooyeon
howooyeon deleted the feat/#155-hiking-record-detail branch June 3, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 트래킹 후 기록 API

2 participants