Skip to content

Commit

Permalink
🐛 fix: 현재 날짜까지 포함하도록 수정 (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
synoti21 committed Nov 28, 2023
1 parent 2a9ae51 commit 2bc36a1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public ResponseAnalysisDto getAnalysisOfUser(Long userId, int year, int month, i
User user = userRepository.getReferenceById(userId);

//현재 날짜
LocalDate currentDate = LocalDate.of(year,month,day);
LocalDate currentDate = LocalDate.of(year,month,day).plusDays(1);

//최근 1주간 유저가 먹은 음식들의 날짜별 HashMap
HashMap<LocalDate, List<BaseNutrition>> nutritionSumOfUserByWeek = getNutritionSumByDateMap(userId, currentDate.minusWeeks(1), currentDate);
Expand Down Expand Up @@ -433,7 +433,7 @@ private void validateFavoriteFood(Long favoriteFoodId, Long userId) {
// 1주일동안 먹은 음식들의 영양성분 총합을 요일을 Key로 한 Map을 통해 반환
private HashMap<LocalDate, List<BaseNutrition>> getNutritionSumByDateMap(Long userId, LocalDate startDate, LocalDate endDate) {
HashMap<LocalDate, List<BaseNutrition>> maps = new HashMap<>();
List<Food> foodList = foodRepository.findAllByUserIdAndDateBetweenOrderByAddedTimeAsc(userId, startDate.plusDays(1), endDate.plusDays(1));
List<Food> foodList = foodRepository.findAllByUserIdAndDateBetweenOrderByAddedTimeAsc(userId, startDate, endDate);
for (Food food : foodList) {
if (maps.containsKey(food.getDate())) {
maps.get(food.getDate()).add(food.getBaseNutrition());
Expand Down

0 comments on commit 2bc36a1

Please sign in to comment.