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

짧은 리뷰 조회 수정 #93 #101

Merged
merged 23 commits into from
Nov 15, 2023
Merged

짧은 리뷰 조회 수정 #93 #101

merged 23 commits into from
Nov 15, 2023

Conversation

hanyMK
Copy link
Contributor

@hanyMK hanyMK commented Nov 10, 2023

📝 개요

짧은 리뷰 조회 수정

🚀 변경사항

  1. 사용자 요구사항에 맞게 reviewId추가
  2. LIKE -> LIKE_COUNT로 변경
  3. spoiler 타입을 boolean -> Boolean으로 변경
  4. 리뷰 좋아요 정렬 기준 조건 변경

🔗 관련 이슈

#93

➕ 기타

@hanyMK hanyMK added Bug fix 버그 발생 및 수정 Docs 문서 작성 및 수정 Feature 새로운 기능 추가 Test 테스트 관련 labels Nov 10, 2023
@hanyMK hanyMK self-assigned this Nov 10, 2023
@jaycobcoder
Copy link
Contributor

테스트를 통과하지 않아서 보니까

from ShortReview shortReview
  inner join Member member1 with member1.id = shortReview.member.id
  inner join Anime anime with anime.id = shortReview.anime.id
  left join ShortReviewLike shortReviewLike with shortReview.id = shortReviewLike.shortReview.id
  left join StarRating starRating with starRating.anime.id = shortReview.anime.id and starRating.member.id = shortReview.member.id
where anime.id = ?1
group by shortReview.id, member1.id
order by shortReviewLike.likeCount desc, shortReview.createdAt desc]
...
Caused by: org.hibernate.query.SemanticException: Could not resolve attribute 'likeCount' of 'io.oduck.api.domain.reviewLike.entity.ShortReviewLike'

이런 예외 메세지가 있었습니다. order by 부분에 shortReviewLike.likeCount desc 쿼리가 나갔는데, likeCount 속성이 없다고 뜨네요. 그래서 엔티티를 보니까

public class ShortReviewLike extends BaseEntity {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "short_review_id")
  private ShortReview shortReview;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "member_id")
  private Member member;
}

엔티티에 likeCount 필드가 없어서 테스트가 통과하지 못한 거 같습니다!

@hanyMK hanyMK added the Setting 개발 환경 세팅 label Nov 11, 2023
@@ -91,12 +95,12 @@ private BooleanExpression cursorCondition(String cursor, Pageable pageable){

if(direction == Direction.ASC) {
return starRating.score.gt(score)
.or(starRating.score.goe(score).and(shortReview.createdAt.lt(scoreCreateAt)))//조회할 좋아요가 크거나 같으면, 첫 커서의 날짜가 크면
.or(starRating.score.goe(score).and(shortReview.createdAt.lt(scoreCreateAt)))
.or(starRating.score.isNotNull().and(shortReview.createdAt.lt(scoreCreateAt)));
Copy link
Contributor

Choose a reason for hiding this comment

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

isNotNull이 아니라 isNull이 되어야 합니다.
image
0부터 "내림차순"인데
isNotNull일 경우 0이 아닌 것도 Count가 조회되어
likeCount: 2가 조회됩니다.

아래도 마찬가지고요

isNull로 해야 좋아요가 없는 것도 제대로 count를 해서 0이 조회 됩니다.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 이해했습니다!

@FaberJoo
Copy link
Contributor

likeCount도 isNull로 바꾸셔야 합니다~

Copy link
Contributor

@FaberJoo FaberJoo left a comment

Choose a reason for hiding this comment

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

🚀

@hanyMK hanyMK merged commit 1d1dea3 into develop Nov 15, 2023
1 check passed
@hanyMK hanyMK deleted the feature/93 branch November 15, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug fix 버그 발생 및 수정 Docs 문서 작성 및 수정 Feature 새로운 기능 추가 Setting 개발 환경 세팅 Test 테스트 관련
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants