Conversation
📝 WalkthroughWalkthrough추천 도메인 기능이 신규 추가되었습니다. FastAPI 추천 서버 호출을 위한 RecommendClient, 추천 및 카테고리 DTO들, MyBatis 매퍼 인터페이스와 XML 매핑, 추천 로직을 수행하고 DB에 저장하는 RecommendService, 이를 노출하는 RecommendController가 포함됩니다. 또한 ErrorCode 열거형에 Lombok Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 상세 피드백🎯 주요 강점계층별 역할 분리가 명확합니다. DTO, Mapper, Service, Controller가 각각의 책임을 잘 수행하고 있으며, MyBatis XML과 Java 인터페이스의 매핑도 일관성 있게 구성되었습니다. 에러 처리 전략이 세밀합니다.
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | PR 제목은 요약 및 전체 상품 추천 기능 구현이라는 주요 변경사항을 명확하게 설명하고 있으며, 이는 추가된 코드 변경사항과 일치합니다. |
| Linked Issues check | ✅ Passed | PR이 연결된 이슈 #50의 모든 요구사항을 충족합니다: 요약별 추천(RecommendController generate 메서드, RecommendService generateAndSave)과 전체 상품 추천(getAll 메서드, getRandomByCategory) 기능이 모두 구현되었습니다. |
| Out of Scope Changes check | ✅ Passed | 모든 변경사항은 추천 API 구현과 카테고리 데이터 접근이라는 정의된 범위 내에 있으며, 범위를 벗어난 변경사항은 없습니다. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
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 @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/main/java/com/ureca/unity/domain/recommend/client/RecommendClient.java`:
- Around line 16-17: Remove the hard-coded fallback by changing the `@Value` on
the baseUrl field in RecommendClient so it references the property without a
default (replace `@Value`("${python.recommend.base-url:http://localhost:8000}")
with `@Value`("${python.recommend.base-url}") ), and add a startup-time validation
in RecommendClient (e.g., in a constructor or `@PostConstruct`) that checks the
baseUrl field and throws a clear IllegalStateException if it's blank; this
ensures the missing python.recommend.base-url property fails application startup
rather than causing generateAndSave() to call a local default at runtime.
In `@src/main/resources/mapper/recommend/RecommendMapper.xml`:
- Around line 38-51: The current selectRandomByCategory SQL uses ORDER BY RAND()
which is a performance bottleneck when getRandomByCategory() loops per category;
replace it with a scalable sampling approach (pick one): 1) add a precomputed
random column (e.g., random_seed or random_key) on product and query using WHERE
category_id=#{categoryId} ORDER BY random_key LIMIT 5, ensuring the column is
updated periodically and indexed; or 2) implement offset sampling by selecting
MAX(product_id) per category and using a calculated random offset (e.g., LIMIT
rand_offset,5) or WHERE product_id >= FLOOR(rand()*max_id) with fallback, or 3)
fetch a small top-N candidate set per category (e.g., LIMIT 100) and perform
application-level random selection in getRandomByCategory(); update the
selectRandomByCategory mapping and corresponding
RecommendService.getRandomByCategory() logic to use the chosen method and add
necessary DB schema/index changes for the precomputed-key option.
🧹 Nitpick comments (4)
src/main/resources/mapper/category/CategoryMapper.xml (1)
7-9: 카테고리 목록 정렬을 명시하면 더 안전합니다.
Line 8에서ORDER BY가 없어 결과 순서가 DB/플랜에 따라 달라질 수 있습니다. 후속 로직이 순서를 기대한다면 흔들릴 수 있으니 명시적 정렬을 권장합니다.♻️ 제안 변경
- SELECT category_id AS categoryId, name FROM category + SELECT category_id AS categoryId, name FROM category + ORDER BY category_idsrc/main/java/com/ureca/unity/domain/recommend/controller/RecommendController.java (1)
45-49:/me경로는 사용자 전용으로 오해될 수 있음
실제 기능은 전체 랜덤 추천이므로/random또는/all같은 경로가 더 직관적입니다. REST API 명명 가이드(공식 문서)와 함께 정리해 주세요.src/main/java/com/ureca/unity/domain/recommend/service/RecommendService.java (2)
33-49: 요청/응답 summaryId 정합성 검증 추가 권장
응답 summaryId가 요청과 다르면 다른 요약의 추천이 저장될 위험이 있습니다. API 스펙(공식 계약 문서)을 기준으로 일치 여부를 확인하고 불일치 시 오류 처리하는 편이 안전합니다.🔧 제안 수정
try { response = recommendClient.recommend(req); } catch (Exception e) { throw new CustomException(ErrorCode.FASTAPI_CALL_FAILED); } + + if (response != null && response.getSummaryId() != summaryId) { + throw new CustomException(ErrorCode.INTERNAL_SERVER_ERROR); // 필요 시 전용 ErrorCode 추가 + }
112-135: 주석 처리된 메서드는 정리 권장
장기간 주석으로 남으면 유지보수 시 혼동을 줍니다. 필요하면 이슈로 남기고 코드에서는 제거하는 편이 깔끔합니다.
Key Changes
작업 내역
💬 공유사항 to 리뷰어
비고
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.