-
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
[BE] feat: 상품 랭킹 기능 추가 #204
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.
랭킹 기능 점수 계산하는거 최고 👍👍
backend/src/main/java/com/funeat/product/persistence/ProductRepository.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/com/funeat/product/persistence/ProductRepository.java
Outdated
Show resolved
Hide resolved
@Query("SELECT new com.funeat.product.dto.ProductReviewCountDto(p, COUNT(r.id)) " | ||
+ "FROM Product p " | ||
+ "LEFT JOIN Review r ON r.product.id = p.id " | ||
+ "WHERE p.averageRating > 3.0 " | ||
+ "GROUP BY p.id") | ||
List<ProductReviewCountDto> findAllProductsAndReviewCountByAverageRatingGreaterThan3(); |
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.
저 궁금한 점이 생겼는데, 만약 서비스를 시작하고 나서 누군가의 계략으로 모든 상품의 평균 평점이 3.0 이하로 만들어버리면 리뷰 랭킹 기능은 상품을 보여줄 수 없는건가요??
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.
저는 개인적으로 평점이 3.0보다 작은 상품들은 랭킹에 노출될 필요가 없다고 생각해요
이 부분은 서비스 정책에 관한 거라 다 같이 얘기해보죠!
backend/src/main/java/com/funeat/product/application/ProductService.java
Outdated
Show resolved
Hide resolved
+ "LEFT JOIN Review r ON r.product.id = p.id " | ||
+ "WHERE p.averageRating > 3.0 " | ||
+ "GROUP BY p.id") | ||
List<ProductReviewCountDto> findAllProductsAndReviewCountByAverageRatingGreaterThan3(); |
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.
이미 반환값을 알고 있기때문에 findAllByAverageRatingGreaterThan3 도 괜찮아보여요!!
+ "LEFT JOIN Review r ON r.product.id = p.id " | ||
+ "WHERE p.averageRating > 3.0 " | ||
+ "GROUP BY p.id") | ||
List<ProductReviewCountDto> findAllProductsAndReviewCountByAverageRatingGreaterThan3(); |
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.
ProductRepository의 findAllProductsAndReviewCountByAverageRatingGreaterThan3() 메서드 명 이대로 괜찮은가..!
반환값 이미 알고 있으니까 위 메소드랑 비슷하게 findAllByAverageRatingGreaterThan3
좋을 것 같아요~~
- findAllProductsAndReviewCountByAverageRatingGreaterThan3() -> findAllByAverageRatingGreaterThan3()
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.
👍👍👍👍
Issue
✨ 구현한 기능
상품 랭킹을 조회하는 기능 구현
1.0 ~ 5.0
의 AvgRating이 나오게 되므로 그 중간에 있는3.0
을 기준으로 기준치 선정3.0
보다 큰 상품에 대해서만 랭킹에 포함될 수 있도록 정책 변경📢 논의하고 싶은 내용
ProductRepository
의findAllProductsAndReviewCountByAverageRatingGreaterThan3()
메서드 명 이대로 괜찮은가..!ProductService
에서 stream 한 번만 돌면서 각 Product의 랭킹 점수 구하고, 내림차순 정렬해서 상위 3개에 해당하는 dto 구하도록 했는데 괜찮나용Product
도메인에서 랭킹 점수를 구하는 비즈니스 로직을 처리하도록 하기 위해,ProductReviewCountDto
에서Product
엔티티를 필드로 가지도록 했는데 괜찮은지..!⏰ 일정