Skip to content

Commit

Permalink
[✨fix/#66] 캘린더 관련 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
junggyo1020 committed Jul 18, 2024
1 parent 56015a1 commit 5a55e3b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ public List<MonthlyDefaultResponseDto> getMonthlyScraps(Long userId, int year, i
LocalDate start = LocalDate.of(year, month, 1);
LocalDate end = start.plusMonths(1).minusDays(1);

List<Scrap> scraps = scrapRepository.findByUserIdAndInternshipAnnouncement_DeadlineBetween(userId, start, end);
List<Scrap> scraps = scrapRepository.findScrapsByUserIdAndDeadlineBetweenOrderByDeadline(userId, start, end);

//deadline 별로 그룹화
Map<LocalDate, List<Scrap>> scrapsByDeadline = scraps.stream()
.collect(Collectors.groupingBy(s -> s.getInternshipAnnouncement().getDeadline()));

return scrapsByDeadline.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(entry -> MonthlyDefaultResponseDto.of(
entry.getKey().toString(),
entry.getValue().stream()
Expand All @@ -79,13 +80,14 @@ public List<MonthlyListResponseDto> getMonthlyScrapsAsList(Long userId, int year
LocalDate start = LocalDate.of(year, month, 1);
LocalDate end = start.plusMonths(1).minusDays(1);

List<Scrap> scraps = scrapRepository.findByUserIdAndInternshipAnnouncement_DeadlineBetween(userId, start, end);
List<Scrap> scraps = scrapRepository.findScrapsByUserIdAndDeadlineBetweenOrderByDeadline(userId, start, end);

//deadline 별로 그룹화
Map<LocalDate, List<Scrap>> scrapsByDeadline = scraps.stream()
.collect(Collectors.groupingBy(s -> s.getInternshipAnnouncement().getDeadline()));

return scrapsByDeadline.entrySet().stream()
.sorted(Map.Entry.comparingByKey())
.map(entry -> MonthlyListResponseDto.of(
entry.getKey().toString(),
entry.getValue().stream()
Expand All @@ -107,7 +109,7 @@ public List<MonthlyListResponseDto> getMonthlyScrapsAsList(Long userId, int year

@Override
public List<DailyScrapResponseDto> getDailyScraps(Long userId, LocalDate date) {
return scrapRepository.findByUserIdAndInternshipAnnouncement_Deadline(userId, date).stream()
return scrapRepository.findScrapsByUserIdAndDeadlineOrderByDeadline(userId, date).stream()
.map(DailyScrapResponseDto::of)
.toList();
}
Expand Down

0 comments on commit 5a55e3b

Please sign in to comment.