From 25b63c483933d8c9d3f85b2a0f0722b9497249bc Mon Sep 17 00:00:00 2001 From: hyeesw Date: Sat, 4 May 2024 20:21:12 +0900 Subject: [PATCH] =?UTF-8?q?[feature]=20#130=20=ED=8F=89=EC=A0=90=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(4=EC=A0=90=20=EB=AF=B8=EB=A7=8C=EC=9D=B4=EB=A9=B4=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=EB=84=88=EC=8A=A4=20=EB=90=98=EB=8F=84=EB=A1=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/match/service/MatchService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java b/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java index bd62ea5350..8df37ecbc0 100644 --- a/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java +++ b/backend/src/main/java/com/coffee/backend/domain/match/service/MatchService.java @@ -221,7 +221,15 @@ public Review saveReview(ReviewDto dto) { int numberOfReviews = reviewRepository.countByReceiverUserId(receiver.getUserId()); double oldCoffeeBean = receiver.getCoffeeBean(); - double newCoffeeBean = oldCoffeeBean + (dto.getRating() * 0.1) * numberOfReviews; + + double baseline = 46.0; + double ratio = 0.1; + double standard = 4.0; + + // 46 + (평점 합계 + (새로운 평점 - 기준 평점) * 반영 비율) / (평점 개수 + 1) + double newCoffeeBean = + baseline + ((oldCoffeeBean - baseline) * numberOfReviews + (dto.getRating() - standard) * ratio) / + (numberOfReviews + 1); receiver.setCoffeeBean(newCoffeeBean); userRepository.save(receiver);