[SW-90] fix: 장소추천 API 카테고리 ENUM 매핑 공백 이슈 수정#85
Conversation
📝 WalkthroughWalkthroughIntroduced whitespace normalization in category matching logic within the RecommendPlaceUseCase service, removing all whitespace from input category strings to ensure consistent equality checks during category name comparison. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/java/swyp/mingling/domain/meeting/service/RecommendPlaceUseCase.java (1)
36-40:⚠️ Potential issue | 🟠 MajorCache key uses raw
category, causing duplicate entries after normalization.The
#categoryin the cache key (line 39) still contains the original whitespace. After this fix,"스터디 카페"and"스터디카페"both resolve to the same enum and produce identical Kakao API calls, but they'll be cached under different keys — resulting in unnecessary cache misses and duplicate cache entries.Normalize
categorybefore it's used in the cache key, e.g., by trimming whitespace at the start ofexecuteor by using the normalized value in the key expression.Proposed fix
public RecommendResponse execute(String midPlace, String category, int page, int size) { + // 공백 제거하여 캐시 키 및 ENUM 매핑 일관성 보장 + String normalizedCategory = category.replaceAll("\\s+", ""); log.info("[CACHE MISS] Call Kakao place search API - midPlace: {}, category: {}, page: {}, size: {}" - , midPlace, category, page, size); + , midPlace, normalizedCategory, page, size); // 1. 카테고리 한글명을 카카오 카테고리 그룹 코드로 변환 - Category categoryEnum = Category.from(category) + Category categoryEnum = Category.from(normalizedCategory) .orElseThrow(BusinessException::purposeNotFound);And update the cache key accordingly:
- key = "'recommend:' + `#midPlace` + ':' + `#category` + ':' + `#page` + ':' + `#size`" + key = "'recommend:' + `#midPlace` + ':' + `#normalizedCategory` + ':' + `#page` + ':' + `#size`"Note: SpEL in
@Cacheableoperates on method parameters, so an alternative is to normalize in a thin controller/facade layer before calling this method, keeping the cache key clean by design.
PR 제목
SW-90 fix: 장소추천 API 카테고리 ENUM 매핑 공백 이슈 수정
작업 유형
작업 내용
체크리스트
참고 사항 (선택)
Summary by CodeRabbit