-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Refactor] TalkRoom 조회 Query 리펙토링 #63
Conversation
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.
수고하셨습니다 !
질문 남겼으니 답변 부탁드립니다. 😊
List<Comment> comments = IntStream.range(1, 6) | ||
.mapToObj(i -> Comment.builder() | ||
.talkRoom(talkRoom) | ||
.user(user) | ||
.content("의견 " + i) | ||
.build()) | ||
.collect(Collectors.toList()); | ||
|
||
for (int i = 0; i < 5; i++) { | ||
commentRepository.save(comments.get(i)); | ||
} |
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.
commentRepository.saveAll(comments)
이렇게 한 번에 저장하는 것도 좋아보입니다 !
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.
음 저도 처음에 saveAll를 했으나 간혈적으로 저장순서가 바뀌는 문제로 테스트가 실패해서 그냥 포문으로 저장 시켰습니다!
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.
제가 알기로 saveAll은 리스트의 순서대로 저장합니다 !
테스트의 다른 부분에서 문제가 발생했던 건 아닐까요 ?
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.
저도 그런걸로 알고있는데 repository 테스트에서 자꾸 테스트 실패가 떴습니다 ㅠㅠ
if (request.getNewImage() != null && !request.getNewImage().isEmpty()) { | ||
request.getNewImage().stream().map(url -> TalkRoomImage.createImages(talkRoom, url)) | ||
.forEach(talkRoomImageRepository::save); | ||
} | ||
|
||
if (request.getRemoveImage() != null && !request.getRemoveImage().isEmpty()) { | ||
request.getRemoveImage().stream().map(s -> talkRoomImageRepository.findByTalkRoomAndImageUrl(talkRoom, s)) | ||
.forEach(talkRoomImageRepository::deleteAll); | ||
} |
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.
해당 if문이 어떤 동작을 하는지 간단하게 설명 부탁드립니다 !
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.
유저가 토론방을 수정할 때, 새로운 이미지를 추가하고 기존에 있던 이미지를 삭제 할때 if문으로 새로운 이미지 혹은 삭제된 이미지 url이 있는지 체크를 하고 있다면 로직을 수행하도록 했습니다!
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.
고생하셨습니다!! 리뷰 남겼으니 확인 부탁드립니다!
} | ||
|
||
public SearchServiceRequest toService() { | ||
return SearchServiceRequest.builder() | ||
.page(page) | ||
.size(size) | ||
.search(search) | ||
.orderType(OrderType.convertToOrderType(order)) | ||
.order(order != null ? order : "re") |
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.
혹시 정렬 기준에서 "re"를 사용하시는 지 궁금해서 리뷰 남깁니다!
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.
정렬 값이 null이 들어올 시 seach.getOrder() 로 가져오게 되면 예외가 발생하기 때문에 null이면 기본으로 최신순으로 정렬하게 하기 위해 짧게 "re" 값으로 넘겨줬습니다!
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.
"re" 값이 불명확한거 같아서 디폴드 값이 무조건 최신순이라면 default나 recent로 값을 넘겨주어도 되지 않을까요?
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.
나중에 수정하도록 하겠습니다!
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.
넵 알겠습니다!
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.
수고하셨습니다 ~ 👍
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.
수고하셨습니다 👊
💡 연관된 이슈
close #61
📝 작업 내용
*. TalkRoom 조회 API Comment 조회 API 변경
💬 리뷰 요구 사항
리뷰 요구 사항은 없습니다.