-
Notifications
You must be signed in to change notification settings - Fork 2
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
[SIX-197] 현재 참여중인 채팅방을 조회하는 로직 구현 #110
Conversation
for (Long chatRoomId : chatRoomIds) { | ||
Query query = new Query(Criteria.where("chat_room_id").is(chatRoomId)); | ||
query.with(Sort.by(Sort.Direction.DESC, "sent_message_time")); | ||
query.limit(1); | ||
ChatMessage latestMessage = mongoTemplate.findOne(query, ChatMessage.class); | ||
if (latestMessage != null) { | ||
latestMessages.add(latestMessage); | ||
} | ||
} |
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.
query.limit(1) 이 마지막 채팅 내용을 가져오는 쿼리인가요?
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.
MySQL의 limit와 같습니다~ query를 마지막으로 보내진 메시지 시간을 내림차순으로 정렬하고 그 쿼리에 대해 1개만 가지고 오면 결국 가장 최근에 보내진 메시지이기 때문입니다~
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.
로직이 복잡하긴 하지만 설명 잘 적어주셔서 어느정도 해석은 된 것 같습니다~
Kudos, SonarCloud Quality Gate passed! |
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.
로직이 어렵긴 하네요.. 수고하셨어요👍
🖊️ 1. Changes
🖼️ 2. Screenshot
❗️ 3. Issues
😌 4. To Reviewer
✅ 5. Plans
🙌 6. Checklist