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

[KAN-99] 리뷰 작성,수정,삭제시 음식점 평균 별점 및 리뷰 개수 반영 #66

Merged
merged 1 commit into from
May 26, 2024

Conversation

goathoon
Copy link
Member

No description provided.

Comment on lines +57 to +63
private fun applyReviewCountAndAvgRating(restaurantId: Long, requestRating: Double) {
val restaurant = restaurantRepository.findById(restaurantId).getOrNull()
?: throw NotFoundRestaurantException()
val beforeCount = restaurant.reviewCount
restaurant.reviewCount = beforeCount + 1
restaurant.ratingAvg = (restaurant.ratingAvg * beforeCount + requestRating) / (beforeCount + 1)
}
Copy link
Member

Choose a reason for hiding this comment

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

요 함수는 여기에 추가하지말고, restaurant에 비즈니스 메서드로 추가해서 진행하면 더 좋을 것 같습니다!

Comment on lines +34 to +45
private fun applyReviewCountAndAvgRating(restaurantId: Long) {
val restaurant = restaurantRepository.findById(restaurantId).getOrNull()
?: throw NotFoundRestaurantException()
val beforeCount = restaurant.reviewCount
if (beforeCount <= 1) {
restaurant.ratingAvg = 0.0
restaurant.reviewCount = 0
} else {
restaurant.ratingAvg = (restaurant.ratingAvg * beforeCount) / (beforeCount - 1)
restaurant.reviewCount = beforeCount - 1
}
}
Copy link
Member

Choose a reason for hiding this comment

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

이것도 마찬가지!

val reviews: List<ReviewResponseDto>
val reviews: List<ReviewResponseDto>,
@Schema(description = "Pagination 정보")
val pageable: Pageable
Copy link
Member

Choose a reason for hiding this comment

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

List가아니라 Page<>로 전달부탁드립니다

@sinkyoungdeok sinkyoungdeok changed the base branch from KAN-97-KAN-98-KAN-99 to KAN-97 May 26, 2024 04:58
Base automatically changed from KAN-97 to KAN-97-KAN-98-KAN-99 May 26, 2024 05:30
@sinkyoungdeok sinkyoungdeok merged commit cf8084f into KAN-97-KAN-98-KAN-99 May 26, 2024
2 of 3 checks passed
@sinkyoungdeok sinkyoungdeok deleted the KAN-99 branch May 26, 2024 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants