Skip to content

Conversation

@kamillcream
Copy link
Contributor

@kamillcream kamillcream commented Jul 31, 2025

📌 PR 개요

  • 중복되는 관광지가 여러 코스에 포함되지 않도록 수정

✅ 변경사항

  • 각 코스의 유사도를 파악 후 관광지를 넣을지 말지 고려.

🔍 체크리스트

  • PR 제목은 명확한가요?
  • 관련 이슈가 있다면 연결했나요?
  • 로컬 테스트는 통과했나요?
  • 코드에 불필요한 부분은 없나요?

📎 관련 이슈

Closes #35


💬 기타 참고사항

Summary by CodeRabbit

  • 신규 기능

    • 유사 코스 중복 추천 방지 기능이 추가되었습니다.
    • 코스 구성 요소 응답에 위도와 경도 정보가 포함되었습니다.
  • 버그 수정

    • 코스 추천 시 최소 3개 이상의 구성 요소를 포함하도록 개선되었습니다.
  • 개선 사항

    • 후보 관광지의 거리 필터가 30km에서 15km로 더 엄격해졌습니다.
    • 다음 장소 추천 시 시간 조건이 30분~3시간 이내로 완화되고, 거리 조건이 15km로 조정되었습니다.
    • 방향성 필터가 제거되어 추천 로직이 단순화되었습니다.
  • 정리

    • 사용하지 않는 코드와 불필요한 로그가 정리되었습니다.

@kamillcream kamillcream requested a review from 7ijin01 July 31, 2025 09:53
@kamillcream kamillcream linked an issue Jul 31, 2025 that may be closed by this pull request
2 tasks
@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

CourseService에 중복 코스 필터링 로직이 추가되어, 80% 이상 동일한 구성 요소(최소 3개 이상)가 겹치는 코스는 추천에서 제외됩니다. 후보 관광지 거리 제한이 30km에서 15km로 강화되고, 시간 필터링은 30분~3시간 이내로 변경되었습니다. 방향성 필터링은 제거되었습니다.

Changes

Cohort / File(s) Change Summary
Course 추천 중복/거리/시간 필터링 개선
src/main/java/com/opendata/domain/course/service/CourseService.java
- isDuplicateCourse 메서드 추가로 80% 이상 겹치는 코스 중복 제거
- 후보 관광지 거리 제한 30km→15km로 강화
- 시간 필터 1시간 정확히→30분~3시간 이내로 완화
- 방향성 필터 및 관련 로깅/코드 제거
- 최소 코스 크기 3개 이상으로 제한
- 불필요한 import 및 주석 제거, 로깅 메시지 수정
CourseComponentResponse 확장
src/main/java/com/opendata/domain/course/dto/response/CourseComponentResponse.java
- lat, lon 필드 추가로 위도/경도 정보 포함
- time 필드에 @JsonFormat 패턴 지정
- from 메서드 수정하여 TourSpot 주소의 위도/경도 필드 매핑

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CourseService
    participant CourseRepository

    User->>CourseService: recommendCourses()
    CourseService->>CourseRepository: fetchCandidates()
    CourseService->>CourseService: getFilteredCandidates (거리 15km 제한)
    loop 각 후보지
        CourseService->>CourseService: findNextAreaDirectional (시간 30분~3시간, 방향성 X)
    end
    CourseService->>CourseService: isDuplicateCourse (80% 이상 중복 확인)
    CourseService-->>User: 추천 코스 반환 (중복/거리/시간 필터 적용)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
중복 빈도 파악 로직 추가, 코스 구성 시 중복 제거 적용 (#35)
거리/시간 조건 강화 및 방향성 제거 (#35)

Poem

🐰
코스 중복, 이젠 안녕!
토끼 발로 거리도 뚝,
시간도 넉넉히 재며
방향은 신경 안 써요.
여행길 한결 새로워진
추천 코스, 뛰뛰빵빵!

— 코스 추천하는 토끼 드림 🗺️✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a40a316 and 40ff2b5.

📒 Files selected for processing (1)
  • src/main/java/com/opendata/domain/course/dto/response/CourseComponentResponse.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#35-course-component-validate

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/com/opendata/domain/course/service/CourseService.java (1)

62-84: 중복 판단 로직이 잘 구현되었으나, 코스 크기 차이가 클 때의 처리를 고려해보세요.

현재 구현은 대부분의 경우 잘 작동하지만, 코스 크기가 크게 다를 때 (예: 3개 vs 10개 구성) Math.min을 사용하면 의도와 다른 결과가 나올 수 있습니다.

예를 들어:

  • 코스 A: 3개 구성 요소
  • 코스 B: 10개 구성 요소, 그 중 3개가 A와 동일

현재 로직: 3/3 = 100% 중복으로 판단
대안: Jaccard 유사도 사용 (교집합/합집합)

-            double overlapRatio = (double) intersection / Math.min(newCourseIds.size(), existingIds.size());
+            // Jaccard 유사도 사용: 교집합 크기 / 합집합 크기
+            Set<Long> union = new HashSet<>(newCourseIds);
+            union.addAll(existingIds);
+            double overlapRatio = (double) intersection / union.size();
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 039d1a0 and a40a316.

📒 Files selected for processing (1)
  • src/main/java/com/opendata/domain/course/service/CourseService.java (5 hunks)
🔇 Additional comments (3)
src/main/java/com/opendata/domain/course/service/CourseService.java (3)

48-50: 중복 코스 필터링 로직이 적절히 구현되었습니다.

최소 3개 이상의 구성 요소를 가진 코스만 추가하고, 중복 여부를 검사하는 로직이 PR 목표에 부합합니다.


96-96: 초기 후보 거리 제한 강화가 적절합니다.

30km에서 15km로 거리 제한을 강화한 것은 더 밀집된 코스를 생성하고 중복 가능성을 줄이는 데 도움이 됩니다.


142-144: 시간 필터링 로직 개선이 우수합니다.

30분에서 3시간 사이의 유연한 시간 범위는 다양한 속도의 관광 활동을 지원하며, 코스 구성의 유연성을 높입니다.

Also applies to: 158-159

from.tourSpot().getAddress().getLatitude(), from.tourSpot().getAddress().getLongitude(),
a.tourSpot().getAddress().getLatitude(), a.tourSpot().getAddress().getLongitude()
);
if (distance > 30.0) {
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

로그 메시지의 거리 기준이 실제 필터와 일치하지 않습니다.

로그에서는 30km를 기준으로 출력하지만 실제 필터링은 15km로 적용됩니다.

-                        if (distance > 30.0) {
+                        if (distance > 15.0) {

Also applies to: 163-163

🤖 Prompt for AI Agents
In src/main/java/com/opendata/domain/course/service/CourseService.java at lines
150 and 163, the log messages mention a distance threshold of 30km, but the
actual filtering uses 15km. Update the log messages to reflect the correct 15km
distance threshold to ensure consistency between logs and filtering logic.

@kamillcream kamillcream merged commit 7a4b8c1 into main Jul 31, 2025
1 of 2 checks passed
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.

[fix] 코스 로직 수정

3 participants