Skip to content

Conversation

@kamillcream
Copy link
Contributor

@kamillcream kamillcream commented Aug 24, 2025

📌 PR 개요

  • 연관 관광지를 기존의 관광지 기준에서 지역 기준으로 변경

✅ 변경사항

  • TourSpotRelated를 Address와 관계 맺음.

🔍 체크리스트

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

📎 관련 이슈

Closes #55


💬 기타 참고사항

Summary by CodeRabbit

  • 신규 기능
    • /api/tourspot/related 엔드포인트 추가로 연관 관광지 데이터 수집·저장 수행
  • 개선 사항
    • 외부 응답이 빈 문자열이어도 안전하게 처리
    • 페이징·메타데이터 수용 및 좌표/카테고리 정보 확장으로 데이터 표현력 향상
  • 성능
    • 비동기 실행 스레드 최대치를 10으로 조정해 자원 사용 안정화
  • 리팩터링
    • 내부 캐시 구조 및 매핑 로직 개편, 연관 관계 정비로 데이터 처리 흐름 개선

@kamillcream kamillcream linked an issue Aug 24, 2025 that may be closed by this pull request
2 tasks
@coderabbitai
Copy link

coderabbitai bot commented Aug 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

연관 관광지 연계를 관광지 기준에서 지역(Address) 기준으로 전환. AddressCache를 지역/이름 2종 캐시로 재구성. TourSpotRelated를 Address 연관으로 재설계하고 필드 추가. DTO 구조와 역직렬화 로직 확장. 서비스 흐름을 비동기 수집→매핑→일괄 저장으로 변경하고 컨트롤러 엔드포인트 추가. 비동기 스레드풀 크기 축소.

Changes

Cohort / File(s) Summary
Address 캐시 재구성
src/main/java/com/opendata/domain/address/cache/AddressCache.java
단일 맵 → byKorName, byAreaId 2종 캐시 구축. 초기화에서 일괄 로드/그룹핑. getByKorName, getByAreaId 제공. getAll 반환 소스 변경.
Address 엔티티 확장
src/main/java/com/opendata/domain/address/entity/Address.java
relatedTourSpots 일대다 추가(@OneToMany(mappedBy="address", cascade=ALL, orphanRemoval=true)).
연관 관광지 도메인 리디자인
src/main/java/com/opendata/domain/tourspot/entity/TourSpotRelated.java, src/main/java/com/opendata/domain/tourspot/entity/TourSpot.java, src/main/java/com/opendata/domain/tourspot/entity/TourSpotAssociated.java
TourSpotRelated가 Address에 @ManyToOne으로 연관. 코드/이름/대·중분류/좌표 필드 추가. TourSpot의 relatedSpots 및 관련 메서드 제거. Associated에 @Setter 추가.
DTO 및 역직렬화 확장
src/main/java/com/opendata/domain/tourspot/dto/TourSpotRelatedDto.java
Header 추가, Body에 페이징 필드 추가, Items에 빈 문자열 처리용 커스텀 Deserializer 도입, AddressItem 필드 교체/추가(기간 표기, 좌표, 허브 분류 등).
매퍼 시그니처 변경
src/main/java/com/opendata/domain/tourspot/mapper/TourSpotRelatedMapper.java
입력을 (Address 컨텍스트 + 원시 필드들)로 변경. 사후 매핑 훅을 Address 할당으로 교체.
서비스 흐름 전환
src/main/java/com/opendata/domain/tourspot/service/TourSpotService.java, src/main/java/com/opendata/domain/tourspot/service/TourSpotRelatedService.java
기존 혼잡도 갱신 제거→연관 관광지 저장 흐름 추가(비동기 수집/검증/매핑/저장). 외부 API 엔드포인트 변경 및 파라미터 조정(baseYm=202504). 스케줄 주석 처리.
컨트롤러 엔드포인트 추가
src/main/java/com/opendata/domain/tourspot/controller/TourSpotController.java
GET /api/tourspot/related 추가 → tourSpotService.saveRelatedTourspot() 호출.
비동기 설정 변경
src/main/java/com/opendata/domain/tourspot/config/AsyncConfig.java
ThreadPoolTaskExecutor 크기 축소(core 20→10, max 40→10).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client as Client
  participant Controller as TourSpotController
  participant Service as TourSpotService
  participant Cache as AddressCache
  participant RelAPI as TourSpotRelatedService
  participant Repo as TourSpotRelatedRepository

  Client->>Controller: GET /api/tourspot/related
  Controller->>Service: saveRelatedTourspot()
  Service->>Cache: getAll() / getByAreaId(areaId)
  rect rgb(245,250,255)
    note over Service,RelAPI: 비동기 수집
    loop 각 Address
      Service->>RelAPI: fetchRelatedTourSpotData(address)
      RelAPI-->>Service: CompletableFuture<Response DTO>
    end
    Service-->>Service: allOf(...).join()
  end
  alt DTO 유효 && 항목 존재
    Service->>Service: 항목→후보 Address 매핑
    Service->>Repo: saveAll(List<TourSpotRelated>)
    Repo-->>Service: persisted entities
  else 데이터 없음/오류
    Service-->>Service: 건너뜀/경고 로그
  end
  Service-->>Controller: 완료
  Controller-->>Client: 200 OK
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Assessment against linked issues

Objective Addressed Explanation
연관 관광지 기준을 지역 기반으로 변경 [#55]
API 주소 변경 (관광지 연관 조회 엔드포인트 전환) [#55]
연관 관광지에 필드 추가 [#55]

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
스레드풀 크기 축소 (src/main/java/com/opendata/domain/tourspot/config/AsyncConfig.java; lines: unknown in provided summary) 이슈 #55의 범위(기준 전환, API 변경, 필드 추가)와 직접적 관련 불명확. 기능 요구에 명시되지 않음.
스케줄링 주석 처리 (src/main/java/com/opendata/domain/tourspot/service/TourSpotService.java; lines: unknown in provided summary) 이슈 #55에 스케줄 조정 요구가 없음. 기능 동작 방식 변경으로 보이나 목적과 직접 연결되지 않음.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • 7ijin01

Poem

귀 twitch, 발톱 딱—코드에 점프한 토끼 한 마리
주소로 묶고, 지역을 따라 폴짝폴짝 정리했지
캐시는 둘로, 스레드는 열로 가지런히
DTO는 빈 문자열도 포근히 안아주니
연관 관광지여, 이제 길 잃지 말지요 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1da903c and 2a520e7.

📒 Files selected for processing (11)
  • src/main/java/com/opendata/domain/address/cache/AddressCache.java (1 hunks)
  • src/main/java/com/opendata/domain/address/entity/Address.java (2 hunks)
  • src/main/java/com/opendata/domain/tourspot/config/AsyncConfig.java (1 hunks)
  • src/main/java/com/opendata/domain/tourspot/controller/TourSpotController.java (1 hunks)
  • src/main/java/com/opendata/domain/tourspot/dto/TourSpotRelatedDto.java (1 hunks)
  • src/main/java/com/opendata/domain/tourspot/entity/TourSpot.java (0 hunks)
  • src/main/java/com/opendata/domain/tourspot/entity/TourSpotAssociated.java (1 hunks)
  • src/main/java/com/opendata/domain/tourspot/entity/TourSpotRelated.java (2 hunks)
  • src/main/java/com/opendata/domain/tourspot/mapper/TourSpotRelatedMapper.java (2 hunks)
  • src/main/java/com/opendata/domain/tourspot/service/TourSpotRelatedService.java (1 hunks)
  • src/main/java/com/opendata/domain/tourspot/service/TourSpotService.java (3 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 refactor/#55-area-related

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@kamillcream kamillcream merged commit 3ae5c9e into main Aug 24, 2025
1 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 25, 2025
4 tasks
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.

[refactor] 연관 관광지 지역 기준으로 변경

2 participants