Conversation
- 채팅방 리스트를 최근 메시지 또는 생성일 기준으로 정렬하는 로직 추가 - `ChatRoom`의 생성일 필드(`createdAt`)에 Getter 추가
- `chat_room`: 멘티, 멘토별 채팅방 목록 조회 인덱스 추가 (`mentee_id`, `mentor_id`) - `chat_message`: 채팅방별 마지막 메시지 조회 인덱스 추가 (`chat_room_id`)
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough채팅방 목록을 최신 메시지 시간순으로 정렬하는 기능이 추가되었습니다. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 코치의 한마디 ✨
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ffd722a4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return Comparator.comparing( | ||
| room -> { | ||
| ChatMessage lastMessage = lastMessageByRoomId.get(room.getId()); | ||
| if (lastMessage == null) { | ||
| return room.getCreatedAt(); |
There was a problem hiding this comment.
Add tie-breaker when sorting chat room previews
The new comparator orders rooms only by createdAt (last message time or room creation time), but chat_room.created_at/chat_message.created_at are defined as DATETIME without sub-second precision in existing migrations, so multiple rooms frequently share the same sort key; in that case Stream.sorted falls back to the repository encounter order, and findAllByMenteeIdOrMentorId has no ORDER BY, which can produce unstable ordering across requests and place effectively newer activity behind older rooms when events occur in the same second. Adding a deterministic secondary key (e.g., last message id or room id descending) would avoid this.
Useful? React with 👍 / 👎.
|
@CodeRabbit 리뷰해줘 |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@backend/fittoring/src/main/java/fittoring/application/chat/service/ChatRoomFacadeService.java`:
- Line 21: The file ChatRoomFacadeService.java contains an unused import
"lombok.NonNull"; remove that import from the top of the file (or run your IDE's
"Optimize Imports"/organize imports) so the class no longer references an unused
symbol and imports are clean.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
backend/fittoring/src/main/java/fittoring/application/chat/service/ChatRoomFacadeService.javabackend/fittoring/src/main/java/fittoring/domain/model/ChatRoom.javabackend/fittoring/src/main/resources/db/migration/V202602251700__add_indexes_to_chat_tables.sql
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import lombok.NonNull; |
There was a problem hiding this comment.
사용되지 않는 import를 제거해주세요.
lombok.NonNull이 import되어 있지만 코드에서 사용되지 않습니다. IDE의 "Optimize Imports" 기능을 활용하면 쉽게 정리할 수 있습니다.
🧹 제거 제안
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import lombok.NonNull;
import lombok.RequiredArgsConstructor;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@backend/fittoring/src/main/java/fittoring/application/chat/service/ChatRoomFacadeService.java`
at line 21, The file ChatRoomFacadeService.java contains an unused import
"lombok.NonNull"; remove that import from the top of the file (or run your IDE's
"Optimize Imports"/organize imports) so the class no longer references an unused
symbol and imports are clean.
dye0p
left a comment
There was a problem hiding this comment.
UI와 관련된 코멘트 하나 있는데 확인해주시면 좋을 것 같아요~ 그 외엔 별다른 코멘트가 없어 승인합니다!
backend/fittoring/src/main/java/fittoring/application/chat/service/ChatRoomFacadeService.java
Outdated
Show resolved
Hide resolved
- 메시지가 없는 채팅방 미리보기 목록 제외 필터 추가 - 테스트 데이터 개선: 메시지가 없는 채팅방 미리보기 목록 제외 시나리오 추가 - RestDocs 문서화 수정: 선택적 필드 옵션 제거 및 설명 수정
Issue Number
closed #1350
As-Is
채팅방 목록이 정렬 기준이 없었습니다.
To-Be
애플리케이션 단 정렬 기준을 추가했습니다.
채팅방 미리보기 기능 관련 인덱스를 추가했습니다.
findAllByMenteeIdOrMentorId로 진행하고 있었기에chat_room에menteeId,mentorId인덱스를 각각 추가SELECT MAX(id) FROM chat_message WHERE chat_room_id IN (...) GROUP BY chat_room_id로 조회하고 있었기에chat_message에chat_room_id인덱스 추가Check List
Summary by CodeRabbit
업데이트 사항