-
Notifications
You must be signed in to change notification settings - Fork 4
[feat] 최근 검색어 저장 로직 추가 #381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
개요친구 요청 알림 수신자를 요청자에서 수신자로 변경하고, 최근 검색어 저장 기능을 위한 POST 엔드포인트를 추가하여 검색어 데이터 저장 및 API 테스트 케이스를 구현했습니다. 변경 사항
코드 리뷰 난이도 평가🎯 2 (Simple) | ⏱️ ~10 분 관련 가능성 있는 PR
토끼의 시
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
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 |
|
Labeler has applied any labels matching special text in your title and description. |
There was a problem hiding this 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을 고려해보세요.검색어 저장 엔드포인트가 잘 구현되었습니다.
@NotBlankvalidation으로 빈 문자열을 방지하고 있습니다.다만 다음 개선사항을 고려해볼 수 있습니다:
- 검색어 최대 길이 제한 추가 (예:
@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
📒 Files selected for processing (3)
src/main/java/ku_rum/backend/domain/friend/application/FriendManageService.javasrc/main/java/ku_rum/backend/domain/search/presentation/RecentSearchController.javasrc/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 어노테이션이 올바르게 추가되었습니다.
| alarmService.notifyAlarm( | ||
| AlarmType.NEW_FRIEND_REQUEST, | ||
| toUser, | ||
| toUser | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Find and examine AlarmService
find . -name "AlarmService.java" -type fRepository: KU-rum/backend
Length of output: 131
🏁 Script executed:
# Search for the notifyAlarm method definition
rg -A 5 "notifyAlarm" --type javaRepository: 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 -20Repository: 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 -80Repository: 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 -100Repository: 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 fRepository: 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 -60Repository: 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 -60Repository: KU-rum/backend
Length of output: 3211
🏁 Script executed:
# Find and examine FriendRequestHandler
find . -name "*FriendRequestHandler*" -type fRepository: 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.javaRepository: KU-rum/backend
Length of output: 821
🏁 Script executed:
# Search for FriendRequestHandler implementation
rg -A 20 "class FriendRequestHandler" --type javaRepository: KU-rum/backend
Length of output: 2380
두 번째 파라미터를 fromUser로 수정하고, 친구 요청 알림 로직 변경이 이 PR의 목적과 일치하는지 확인하세요.
FriendRequestHandler는 object 파라미터로 받은 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.
Test Results 38 files 38 suites 11s ⏱️ Results for commit 96de498. |
📝작업 내용
최근 검색어 저장 로직 추가
Summary by CodeRabbit
릴리스 노트
새로운 기능
버그 수정
테스트
✏️ Tip: You can customize this high-level summary in your review settings.