@@ -39,8 +39,12 @@ public List<UserInfoResponseDto.DailyNewsCheckDto> getDailyNewsCheck(Long userId
3939 return IntStream .range (0 , 7 )
4040 .mapToObj (i -> {
4141 LocalDate date = monday .plusDays (i );
42- LocalDateTime start = date .atStartOfDay (zone ).toLocalDateTime ();
43- LocalDateTime end = date .atTime (LocalTime .MAX ).atZone (zone ).toLocalDateTime ();
42+
43+ ZonedDateTime zonedStart = date .atStartOfDay (zone );
44+ ZonedDateTime zonedEnd = date .atTime (LocalTime .MAX ).atZone (zone );
45+
46+ LocalDateTime start = zonedStart .toInstant ().atZone (ZoneId .systemDefault ()).toLocalDateTime ();
47+ LocalDateTime end = zonedEnd .toInstant ().atZone (ZoneId .systemDefault ()).toLocalDateTime ();
4448
4549 boolean checked = query
4650 .selectOne ()
@@ -49,15 +53,31 @@ public List<UserInfoResponseDto.DailyNewsCheckDto> getDailyNewsCheck(Long userId
4953 .and (newsHistory .readAt .between (start , end )))
5054 .fetchFirst () != null ;
5155
52- return new UserInfoResponseDto .DailyNewsCheckDto (date .getDayOfMonth (), checked );
56+ return new UserInfoResponseDto .DailyNewsCheckDto (date .getDayOfMonth (), checked , date );
5357 })
5458 .toList ();
5559 }
5660
5761 public int countConsecutiveDays (List <UserInfoResponseDto .DailyNewsCheckDto > checks ) {
58- return (int ) checks .stream ()
59- .sorted (Comparator .comparingInt (UserInfoResponseDto .DailyNewsCheckDto ::getDay ))
60- .takeWhile (UserInfoResponseDto .DailyNewsCheckDto ::getChecked )
61- .count ();
62+ List <UserInfoResponseDto .DailyNewsCheckDto > sorted = checks .stream ()
63+ .filter (check -> check .getDate () != null )
64+ .sorted (Comparator .comparing (UserInfoResponseDto .DailyNewsCheckDto ::getDate ))
65+ .toList ();
66+
67+ int count = 0 ;
68+ LocalDate expected = null ;
69+
70+ for (UserInfoResponseDto .DailyNewsCheckDto check : sorted ) {
71+ if (!Boolean .TRUE .equals (check .getChecked ())) break ;
72+ if (expected == null ) {
73+ expected = check .getDate ();
74+ } else if (!check .getDate ().equals (expected )) {
75+ break ;
76+ }
77+ count ++;
78+ expected = expected .plusDays (1 );
79+ }
80+
81+ return count ;
6282 }
6383}
0 commit comments