Skip to content

[SW-90] fix: 장소추천 API 카테고리 ENUM 매핑 공백 이슈 수정#85

Merged
casylm merged 1 commit intodevelopfrom
fix/SW-90-recommend-places-query-normalization
Feb 7, 2026
Merged

[SW-90] fix: 장소추천 API 카테고리 ENUM 매핑 공백 이슈 수정#85
casylm merged 1 commit intodevelopfrom
fix/SW-90-recommend-places-query-normalization

Conversation

@sik2Boii
Copy link
Copy Markdown
Collaborator

@sik2Boii sik2Boii commented Feb 7, 2026

PR 제목

SW-90 fix: 장소추천 API 카테고리 ENUM 매핑 공백 이슈 수정

작업 유형

  • 새로운 기능 추가
  • 기존 기능 수정
  • 버그 수정
  • 리팩토링
  • 문서 업데이트
  • 테스트 추가/수정

작업 내용

  • 장소추천 API 카테고리 요청 파라미터 공백 제거 정규화 처리

체크리스트

  • 코드 컴파일 및 테스트 통과
  • 커밋 메시지 컨벤션 준수
  • 불필요한 디버깅 코드 제거

참고 사항 (선택)

  • 프론트에서 전달되는 카테고리 문자열에 공백이 포함될 수 있어 서버에서 공백 제거 후 ENUM 매핑하도록 수정
  • 기존 API 스펙 변경 없음

Summary by CodeRabbit

  • Bug Fixes
    • Improved place recommendation accuracy by fixing category matching logic to ensure consistent results.

@sik2Boii sik2Boii self-assigned this Feb 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

Introduced 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

Cohort / File(s) Summary
Category Normalization
src/main/java/swyp/mingling/domain/meeting/service/RecommendPlaceUseCase.java
Normalized input category by stripping whitespace and updated matching logic to compare against the normalized value for accurate category equality checks.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • rkdrudgns0412
  • casylm
  • Yongseok-2

Poem

🐰 A space here, a space there—
No more confusion in the air!
Categories now align just right,
Stripped of whitespace, clean and bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing whitespace handling in ENUM category mapping for the place recommendation API.
Description check ✅ Passed The pull request description follows the required template structure with all sections completed, including work type, tasks, and checklist items marked appropriately.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/SW-90-recommend-places-query-normalization

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

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

Copy link
Copy Markdown
Collaborator

@casylm casylm left a comment

Choose a reason for hiding this comment

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

확인완료

@casylm casylm merged commit 286b936 into develop Feb 7, 2026
1 check was pending
Copy link
Copy Markdown

@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: 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 | 🟠 Major

Cache key uses raw category, causing duplicate entries after normalization.

The #category in 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 category before it's used in the cache key, e.g., by trimming whitespace at the start of execute or 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 @Cacheable operates 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.

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.

2 participants