Skip to content

Conversation

@kmw10693
Copy link
Contributor

@kmw10693 kmw10693 commented Jan 5, 2026

📝작업 내용

최근 검색어 저장 로직 추가

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 최근 검색 키워드 저장 기능 추가
  • 버그 수정

    • 친구 요청 알림 수신자가 올바르게 변경됨
  • 테스트

    • 최근 검색 저장 기능에 대한 테스트 케이스 추가

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

개요

친구 요청 알림 수신자를 요청자에서 수신자로 변경하고, 최근 검색어 저장 기능을 위한 POST 엔드포인트를 추가하여 검색어 데이터 저장 및 API 테스트 케이스를 구현했습니다.

변경 사항

결집 / 파일 변경 요약
알림 로직
src/main/java/ku_rum/backend/domain/friend/application/FriendManageService.java
NEW_FRIEND_REQUEST 알림 수신자를 fromUser에서 toUser로 변경하여 친구 요청 알림이 요청 대상자에게 전달되도록 수정
최근 검색어 API
src/main/java/ku_rum/backend/domain/search/presentation/RecentSearchController.java
검색어 저장을 위한 POST 엔드포인트 추가 (save(String keyword))로 @NotBlank 유효성 검사 및 서비스 호출 구현
최근 검색어 컨트롤러 테스트
src/test/java/ku_rum/backend/domain/search/presentation/RecentSearchControllerTest.java
saveRecentSearch() 테스트 케이스 추가로 POST /api/v1/notices/searches/recent 엔드포인트의 동작 및 문서화 검증

코드 리뷰 난이도 평가

🎯 2 (Simple) | ⏱️ ~10 분

관련 가능성 있는 PR

토끼의 시

🐰 알림은 받는 이에게로,
검색어는 저장되고,
테스트는 모두 초록불이네!
작은 변화가 모여
더 나은 서비스를 만드누나. 🌟

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning PR 설명이 템플릿의 필수 항목인 이슈 번호, 상세 내용, 리뷰 요구사항이 누락되어 있습니다. 이슈 번호(#381), 체크리스트 형식의 작업 내용, 상세 설명, 리뷰 요구사항을 추가하여 템플릿을 완성해주세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 최근 검색어 저장 로직 추가라는 명확한 주요 변경사항을 직관적으로 요약하고 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings

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.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Labeler has applied any labels matching special text in your title and description.
Please review the labels and make any necessary changes.

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

Fix all issues with AI Agents 🤖
In
@src/main/java/ku_rum/backend/domain/friend/application/FriendManageService.java:
- Around line 44-48: Call to alarmService.notifyAlarm currently passes toUser
twice; change the second argument to fromUser so the object used by
FriendRequestHandler (which formats "%s 님이 친구 신청을 했어요") is the sender, i.e.,
replace alarmService.notifyAlarm(AlarmType.NEW_FRIEND_REQUEST, toUser, toUser)
with alarmService.notifyAlarm(AlarmType.NEW_FRIEND_REQUEST, fromUser, toUser)
and confirm this notification logic change belongs in this PR that is meant for
adding recent-search persistence.
🧹 Nitpick comments (1)
src/main/java/ku_rum/backend/domain/search/presentation/RecentSearchController.java (1)

41-49: 기본 구현은 올바르지만, 추가 validation을 고려해보세요.

검색어 저장 엔드포인트가 잘 구현되었습니다. @NotBlank validation으로 빈 문자열을 방지하고 있습니다.

다만 다음 개선사항을 고려해볼 수 있습니다:

  • 검색어 최대 길이 제한 추가 (예: @Size(max = 100))
  • 필요시 공백 문자 trim 처리
선택적 개선안
 @PostMapping
 public BaseResponse<Void> save(
         @RequestParam
-        @NotBlank(message = "검색어는 필수입니다.")
+        @NotBlank(message = "검색어는 필수입니다.") 
+        @Size(max = 100, message = "검색어는 100자를 초과할 수 없습니다.")
         String keyword) {

-    recentSearchService.save(keyword);
+    recentSearchService.save(keyword.trim());
     return BaseResponse.ok(null);
 }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 485920b and 96de498.

📒 Files selected for processing (3)
  • src/main/java/ku_rum/backend/domain/friend/application/FriendManageService.java
  • src/main/java/ku_rum/backend/domain/search/presentation/RecentSearchController.java
  • src/test/java/ku_rum/backend/domain/search/presentation/RecentSearchControllerTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
src/test/java/ku_rum/backend/domain/search/presentation/RecentSearchControllerTest.java (2)

28-28: LGTM!

새로운 POST 엔드포인트 테스트를 위해 필요한 import가 올바르게 추가되었습니다.


146-177: LGTM!

최근 검색어 저장 API에 대한 테스트가 잘 작성되었습니다. 서비스 모킹, API 호출, 응답 검증, RestDocs 문서화가 모두 적절하게 구현되어 있습니다.

src/main/java/ku_rum/backend/domain/search/presentation/RecentSearchController.java (1)

5-5: LGTM!

새로운 검색어 저장 엔드포인트에 필요한 validation 어노테이션이 올바르게 추가되었습니다.

Comment on lines +44 to +48
alarmService.notifyAlarm(
AlarmType.NEW_FRIEND_REQUEST,
toUser,
toUser
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find and examine AlarmService
find . -name "AlarmService.java" -type f

Repository: KU-rum/backend

Length of output: 131


🏁 Script executed:

# Search for the notifyAlarm method definition
rg -A 5 "notifyAlarm" --type java

Repository: KU-rum/backend

Length of output: 4621


🏁 Script executed:

# Check FriendManageService current state around lines 44-48
fd "FriendManageService.java" -x cat -n {} | sed -n '35,55p'

Repository: KU-rum/backend

Length of output: 1012


🏁 Script executed:

# Get git log for FriendManageService to see recent changes
git log --oneline -- "**/FriendManageService.java" | head -20

Repository: KU-rum/backend

Length of output: 117


🏁 Script executed:

# Get the full AlarmService.java to understand parameter semantics
cat -n ./src/main/java/ku_rum/backend/domain/alarm/application/AlarmService.java | head -80

Repository: KU-rum/backend

Length of output: 4430


🏁 Script executed:

# Get git diff for FriendManageService to see what changed
git diff HEAD~1 -- "**/FriendManageService.java" | head -100

Repository: KU-rum/backend

Length of output: 86


🏁 Script executed:

# Check the Friend domain model to understand data structure
find . -name "Friend.java" -path "*/domain/friend/*" -type f -exec cat -n {} \;

Repository: KU-rum/backend

Length of output: 1777


🏁 Script executed:

# Find AlarmMessageHandler interface/class
find . -name "AlarmMessageHandler*" -type f

Repository: KU-rum/backend

Length of output: 220


🏁 Script executed:

# Check the NEW_FRIEND_REQUEST handler implementation
rg -A 15 "NEW_FRIEND_REQUEST" --type java | head -60

Repository: KU-rum/backend

Length of output: 4852


🏁 Script executed:

# Get the full FriendManageService to understand context
cat -n ./src/main/java/ku_rum/backend/domain/friend/application/FriendManageService.java | head -60

Repository: KU-rum/backend

Length of output: 3211


🏁 Script executed:

# Find and examine FriendRequestHandler
find . -name "*FriendRequestHandler*" -type f

Repository: KU-rum/backend

Length of output: 139


🏁 Script executed:

# Get the AlarmMessageHandler interface definition
cat -n ./src/main/java/ku_rum/backend/domain/alarm/application/AlarmMessageHandler.java

Repository: KU-rum/backend

Length of output: 821


🏁 Script executed:

# Search for FriendRequestHandler implementation
rg -A 20 "class FriendRequestHandler" --type java

Repository: KU-rum/backend

Length of output: 2380


두 번째 파라미터를 fromUser로 수정하고, 친구 요청 알림 로직 변경이 이 PR의 목적과 일치하는지 확인하세요.

FriendRequestHandlerobject 파라미터로 받은 User 객체의 닉네임을 사용하여 알림 메시지를 생성합니다. 현재 코드에서는 두 파라미터가 모두 toUser(친구 요청을 받는 사람)로 설정되어 있지만, 알림 메시지 템플릿이 "%s 님이 친구 신청을 했어요"이므로 object 파라미터는 fromUser(친구 요청을 보낸 사람)여야 합니다.

올바른 호출:

alarmService.notifyAlarm(
    AlarmType.NEW_FRIEND_REQUEST,
    fromUser,
    toUser
);

또한 이 PR의 목적이 "최근 검색어 저장 로직 추가"인데, 친구 요청 알림 로직 변경이 포함된 이유를 확인하세요.

🤖 Prompt for AI Agents
In
@src/main/java/ku_rum/backend/domain/friend/application/FriendManageService.java
around lines 44-48, Call to alarmService.notifyAlarm currently passes toUser
twice; change the second argument to fromUser so the object used by
FriendRequestHandler (which formats "%s 님이 친구 신청을 했어요") is the sender, i.e.,
replace alarmService.notifyAlarm(AlarmType.NEW_FRIEND_REQUEST, toUser, toUser)
with alarmService.notifyAlarm(AlarmType.NEW_FRIEND_REQUEST, fromUser, toUser)
and confirm this notification logic change belongs in this PR that is meant for
adding recent-search persistence.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Test Results

 38 files   38 suites   11s ⏱️
157 tests 157 ✅ 0 💤 0 ❌
158 runs  158 ✅ 0 💤 0 ❌

Results for commit 96de498.

@kmw10693 kmw10693 merged commit ef24ac2 into develop Jan 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants