Skip to content
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

Merged
merged 7 commits into from
Oct 11, 2024

Conversation

Kimprodp
Copy link
Contributor

@Kimprodp Kimprodp commented Oct 8, 2024


🚀 어떤 기능을 구현했나요 ?

  • 자신이 받은 리뷰 요약 조회 기능을 구현했습니다.

🔥 어떻게 해결했나요 ?

  • /v2/reviews/summary : 리뷰 그룹에 등록된 리뷰 수와 리뷰 그룹 정보를 반환합니다.

📝 어떤 부분에 집중해서 리뷰해야 할까요?

  • 꼼꼼히 봐주세요~

📚 참고 자료, 할 말

Copy link

github-actions bot commented Oct 8, 2024

Test Results

120 tests  +5   120 ✅ +5   4s ⏱️ -1s
 47 suites +3     0 💤 ±0 
 47 files   +3     0 ❌ ±0 

Results for commit 6533eb8. ± Comparison against base commit 65bdfb3.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@donghoony donghoony left a 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);
Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewGroupId에 인덱스 걸려있어서 현재 쿼리로 인덱스 걸리지 않나요?

Comment on lines 55 to 60
ReviewGroup reviewGroup = reviewGroupRepository.save(new ReviewGroup(
"ted",
"review-me",
"reviewRequestCode",
"groupAccessCode"
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewGroupFixture 를 사용하면 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗차차 수정할게요~

Copy link
Contributor

@skylar1220 skylar1220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빠른 테드쓰~ 소소 제안쓰~

Comment on lines 58 to 73
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)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reivewRepositoy.count 하면 다른 리뷰그룹의 리뷰까지 함께 가져오는 결과를 의미하니 이렇게 list의 크기로 검증하는 건 어떨까요?

Suggested change
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())
);

Copy link
Contributor Author

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 리뷰_그룹에_등록된_리뷰_요약_정보를_반환한다() {
Copy link
Contributor

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에 대한 테스트 메서드를 만드는 게 더 맞겠다는 생각도 드네요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금 다른 레포지토리에서 JPA가 만들어준 메서드는 따로 테스트 하고 있지 않아서.. 우선 기존 테스트에 그룹 하나 추가하는 걸로도 알 수 있을 것 같아 추가했어요~

Copy link
Contributor

@skylar1220 skylar1220 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리반확완👍

Copy link
Contributor

@nayonsoso nayonsoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고 많았습니다~ ㅎㅎ
사소해서 커멘트 남기기조차 민망하지만 그냥 넘어가기에는 뭣한 부분 코멘트 남겼습니다~

Comment on lines 67 to 72
// when
ReceivedReviewsSummaryResponse actual = reviewSummaryService.getReviewSummary(
reviewGroup1.getReviewRequestCode());
// then
assertAll(
() -> assertThat(actual.projectName()).isEqualTo(reviewGroup1.getProjectName()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개행해주세욧!

Comment on lines +26 to +30
return new ReceivedReviewsSummaryResponse(
reviewGroup.getProjectName(),
reviewGroup.getReviewee(),
totalReviewCount
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[이건 그냥 소감]
요런 컨벤션은 없었던 것 같긴 한데 시원시원한 개행이라 좋네요 ㅎㅎ

@Kimprodp Kimprodp merged commit 5815e48 into develop Oct 11, 2024
2 checks passed
@donghoony donghoony deleted the be/feat/794-received-revieew-summary branch October 11, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BE] 받은 리뷰 요약 조회 API를 구현한다.
4 participants