Skip to content

Commit

Permalink
♻️ refactor: 반올림 간소화 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
synoti21 committed Nov 6, 2023
1 parent 13c8eee commit 7ee2503
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/main/java/com/diareat/diareat/food/service/FoodService.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,17 @@ public ResponseScoreBestWorstDto getScoreOfUserWithBestAndWorstFoods(Long userId

ResponseRankUserDto scoresOfUser = calculateUserScoreThisWeek(targetUser, LocalDate.now().with(DayOfWeek.MONDAY), LocalDate.now());

totalScore = scoresOfUser.getTotalScore();
kcalScore = scoresOfUser.getCalorieScore();
carbohydrateScore = scoresOfUser.getCarbohydrateScore();
proteinScore = scoresOfUser.getProteinScore();
fatScore = scoresOfUser.getFatScore();
totalScore = Math.round((scoresOfUser.getTotalScore() * 100.0))/ 100.0;
kcalScore = Math.round((scoresOfUser.getCalorieScore() * 100.0)) / 100.0;
carbohydrateScore = Math.round((scoresOfUser.getCarbohydrateScore() * 100.0)) / 100.0;
proteinScore = Math.round((scoresOfUser.getProteinScore() * 100.0)) / 100.0;
fatScore = Math.round((scoresOfUser.getFatScore() * 100.0 ))/ 100.0;


//Dto의 형식에 맞게 Best3와 Worst3 음식 계산
List<ResponseSimpleFoodDto> simpleBestFoodList = getBestFoodByWeek(userId).getRankFoodList();
List<ResponseSimpleFoodDto> simpleWorstFoodList = getWorstFoodByWeek(userId).getRankFoodList();

//반올림
totalScore = Math.round(totalScore * 100.0) / 100.0;
kcalScore = Math.round(kcalScore * 100.0) / 100.0;
carbohydrateScore = Math.round(carbohydrateScore * 100.0) / 100.0;
proteinScore = Math.round(proteinScore * 100.0) / 100.0;
fatScore = Math.round(fatScore * 100.0) / 100.0;


return ResponseScoreBestWorstDto.of(kcalScore, carbohydrateScore, proteinScore, fatScore, totalScore, simpleBestFoodList, simpleWorstFoodList);
}

Expand Down

0 comments on commit 7ee2503

Please sign in to comment.