-
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
[BE] feat: 받은 리뷰 요약 조회 API 구현 #796
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.
👍🏻 테스트 하나만 작성해주세용!~
테스트 커밋 못 봤네요 ㅎㅎ 고생했습니다 😁
@@ -38,4 +38,6 @@ AND CAST(r.created_at AS DATE) <= :createdDate | |||
default boolean existsOlderReviewInGroup(long reviewGroupId, long reviewId, LocalDate createdDate) { | |||
return existsOlderReviewInGroupInLong(reviewGroupId, reviewId, createdDate) > 0; | |||
} | |||
|
|||
int countByReviewGroupId(long reviewGroupId); |
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.
인덱스 걸려있으면 빠를까요? 아래 JPQL과 쿼리 차이나 성능 차이가 있을까요?
@Query("SELECT COUNT(r.id) FROM Review r WHERE r.reviewGroupId = :reviewGroupId)
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.
reviewGroupId에 인덱스 걸려있어서 현재 쿼리로 인덱스 걸리지 않나요?
ReviewGroup reviewGroup = reviewGroupRepository.save(new ReviewGroup( | ||
"ted", | ||
"review-me", | ||
"reviewRequestCode", | ||
"groupAccessCode" | ||
)); |
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.
ReviewGroupFixture
를 사용하면 어떨까요?
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.
빠른 테드쓰~ 소소 제안쓰~
Review review1 = new Review(template.getId(), reviewGroup.getId(), List.of()); | ||
Review review2 = new Review(template.getId(), reviewGroup.getId(), List.of()); | ||
Review review3 = new Review(template.getId(), reviewGroup.getId(), List.of()); | ||
reviewRepository.saveAll(List.of(review1, review2, review3)); | ||
long numberOfReviews = reviewRepository.count(); | ||
|
||
// when | ||
ReceivedReviewsSummaryResponse actual = reviewSummaryService.getReviewSummary( | ||
reviewGroup.getReviewRequestCode()); | ||
|
||
// then | ||
assertAll( | ||
() -> assertThat(actual.projectName()).isEqualTo(reviewGroup.getProjectName()), | ||
() -> assertThat(actual.revieweeName()).isEqualTo(reviewGroup.getReviewee()), | ||
() -> assertThat(actual.totalReviewCount()).isEqualTo(numberOfReviews) | ||
); |
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.
reivewRepositoy.count 하면 다른 리뷰그룹의 리뷰까지 함께 가져오는 결과를 의미하니 이렇게 list의 크기로 검증하는 건 어떨까요?
Review review1 = new Review(template.getId(), reviewGroup.getId(), List.of()); | |
Review review2 = new Review(template.getId(), reviewGroup.getId(), List.of()); | |
Review review3 = new Review(template.getId(), reviewGroup.getId(), List.of()); | |
reviewRepository.saveAll(List.of(review1, review2, review3)); | |
long numberOfReviews = reviewRepository.count(); | |
// when | |
ReceivedReviewsSummaryResponse actual = reviewSummaryService.getReviewSummary( | |
reviewGroup.getReviewRequestCode()); | |
// then | |
assertAll( | |
() -> assertThat(actual.projectName()).isEqualTo(reviewGroup.getProjectName()), | |
() -> assertThat(actual.revieweeName()).isEqualTo(reviewGroup.getReviewee()), | |
() -> assertThat(actual.totalReviewCount()).isEqualTo(numberOfReviews) | |
); | |
List<Review> reviews = List.of( | |
new Review(template.getId(), reviewGroup.getId(), List.of()), | |
new Review(template.getId(), reviewGroup.getId(), List.of()), | |
new Review(template.getId(), reviewGroup.getId(), List.of()) | |
); | |
reviewRepository.saveAll(reviews); | |
// when | |
ReceivedReviewsSummaryResponse actual = reviewSummaryService.getReviewSummary( | |
reviewGroup.getReviewRequestCode()); | |
// then | |
assertAll( | |
() -> assertThat(actual.projectName()).isEqualTo(reviewGroup.getProjectName()), | |
() -> assertThat(actual.revieweeName()).isEqualTo(reviewGroup.getReviewee()), | |
() -> assertThat(actual.totalReviewCount()).isEqualTo(reviews.size()) | |
); |
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.
굿 깔끔 반영했어요~
private QuestionRepository questionRepository; | ||
|
||
@Test | ||
void 리뷰_그룹에_등록된_리뷰_요약_정보를_반환한다() { |
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.
다른 reviewGroup의 review가 아닌 내 reviewGroup의 review 갯수만 반환하는지 확인하는 로직이 필요할 것 같아요~ 쓰고보니 repository의 countByReviewGroupId에 대한 테스트 메서드를 만드는 게 더 맞겠다는 생각도 드네요!
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.
지금 다른 레포지토리에서 JPA가 만들어준 메서드는 따로 테스트 하고 있지 않아서.. 우선 기존 테스트에 그룹 하나 추가하는 걸로도 알 수 있을 것 같아 추가했어요~
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.
수고 많았습니다~ ㅎㅎ
사소해서 커멘트 남기기조차 민망하지만 그냥 넘어가기에는 뭣한 부분 코멘트 남겼습니다~
// when | ||
ReceivedReviewsSummaryResponse actual = reviewSummaryService.getReviewSummary( | ||
reviewGroup1.getReviewRequestCode()); | ||
// then | ||
assertAll( | ||
() -> assertThat(actual.projectName()).isEqualTo(reviewGroup1.getProjectName()), |
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.
개행해주세욧!
return new ReceivedReviewsSummaryResponse( | ||
reviewGroup.getProjectName(), | ||
reviewGroup.getReviewee(), | ||
totalReviewCount | ||
); |
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.
[이건 그냥 소감]
요런 컨벤션은 없었던 것 같긴 한데 시원시원한 개행이라 좋네요 ㅎㅎ
🚀 어떤 기능을 구현했나요 ?
🔥 어떻게 해결했나요 ?
/v2/reviews/summary
: 리뷰 그룹에 등록된 리뷰 수와 리뷰 그룹 정보를 반환합니다.📝 어떤 부분에 집중해서 리뷰해야 할까요?
📚 참고 자료, 할 말