diff --git a/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java b/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java index 7f919a9..db4618f 100644 --- a/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java +++ b/src/main/java/com/_8attery/seesaw/service/battery/BatteryService.java @@ -259,18 +259,6 @@ public List getUserSleep(Long userId, Integer year, Integer mo int todayDay = date.getDayOfMonth(); // Extract the day of the month for (SleepResponseDto sleepRes : res) { - Integer curSleep = batteryRepository.findUserCurSleep(userId); - if (todayDay == sleepRes.getDay() && curSleep != null) { - sleepRes.setSleep(curSleep); - // 오늘 수면량 입력했으면 따로 확인 - if (curSleep < sleepGoal * 0.5) { - sleepRes.setColor(3); - } else if (curSleep < sleepGoal && curSleep >= sleepGoal * 0.5) { - sleepRes.setColor(2); - } else if (curSleep >= sleepGoal) { - sleepRes.setColor(1); - } - } for (SleepDto result : resultList) { if (result.getDay() == sleepRes.getDay()) { @@ -294,6 +282,19 @@ public List getUserSleep(Long userId, Integer year, Integer mo } } } + + Integer curSleep = batteryRepository.findUserCurSleep(userId); + if (todayDay == sleepRes.getDay() && curSleep != null) { + sleepRes.setSleep(curSleep); + // 오늘 수면량 입력했으면 따로 확인 + if (curSleep < sleepGoal * 0.5) { + sleepRes.setColor(3); + } else if (curSleep < sleepGoal && curSleep >= sleepGoal * 0.5) { + sleepRes.setColor(2); + } else if (curSleep >= sleepGoal) { + sleepRes.setColor(1); + } + } } return res;