Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Happy-HOBAK/happinesSQL-BE
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
KkomSang committed Jun 9, 2024
2 parents 3184866 + e176b1a commit 4d81b4a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public AverageHappinessResponseDto getAnnualHappiness(User user) {
return ReportConverter.toAverageHappinessResponseDto(averageHappiness,level,level.getEmoji()); }
public AverageHappinessResponseDto getMonthlyHappiness(User user) {
LocalDateTime startOfMonth = LocalDateTime.of(currentYear, currentMonth, 1, 0, 0);
LocalDateTime endOfMonth = LocalDateTime.of(currentYear, currentMonth, 31, 23, 59, 59);
LocalDateTime endOfMonth = LocalDateTime.of(currentYear, currentMonth, currentDate.lengthOfMonth(), 23, 59, 59);
double totalHappiness = recordRepository.findAllByCreatedAtBetweenAndUser(startOfMonth, endOfMonth, user).stream().mapToInt(Record::getHappiness).sum();
double averageHappiness = totalHappiness / recordRepository.countAllByCreatedAtBetweenAndUser(startOfMonth, endOfMonth, user);
averageHappiness = Math.round(averageHappiness * 100.0) / 100.0;
Expand Down

0 comments on commit 4d81b4a

Please sign in to comment.