Skip to content

Commit

Permalink
refactor: findDatesWithTodosByMonth() 메서드에서 addAll() 메서드 대신 생성자 호출 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeonghee-Han committed May 9, 2024
1 parent 2d62148 commit 9dda369
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/umc/mada/todo/service/ChartService.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,16 @@ public StatisticsResponseDto monthlyStatistics(Authentication authentication, Lo

public Map<String, Object> findDatesWithTodosByMonth(Authentication authentication, YearMonth yearMonth) {
User user = userRepository.findByAuthId(authentication.getName()).orElseThrow(()-> new RuntimeException("올바른 유저 ID가 아닙니다."));
Set<Integer> datesWithTodosSet = new HashSet<>();

// 투두
List<Integer> todoDates = todoRepository.findDistinctDaysByUserIdAndYearMonth(user.getId(), yearMonth.toString());
datesWithTodosSet.addAll(todoDates);
Set<Integer> datesWithTodosSet = new HashSet<>(todoRepository.findDistinctDaysByUserIdAndYearMonth(user.getId(), yearMonth.toString()));

// 반복 투두
List<Integer> recurringTodoDates = repeatTodoRepository.findDistinctDaysByUserIdAndYearMonth(user.getId(), yearMonth.toString());
datesWithTodosSet.addAll(recurringTodoDates);
datesWithTodosSet.addAll(repeatTodoRepository.findDistinctDaysByUserIdAndYearMonth(user.getId(), yearMonth.toString()));

List<Integer> datesWithTodos = new ArrayList<>(datesWithTodosSet);
Collections.sort(datesWithTodos);

Map<String, Object> map = new LinkedHashMap<>();
Map<String, Object> data = new LinkedHashMap<>();
data.put("datesWithTodos", datesWithTodos);
Expand Down

0 comments on commit 9dda369

Please sign in to comment.