Skip to content

Commit

Permalink
#98 [fix] : 가장 많이 되는 시간이 이어지지 않는 문제를 해결한다 (record는 불변 객체)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbang105 committed Oct 25, 2024
1 parent 3a347ae commit 4ce46db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/side/onetime/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,17 @@ private List<GetMostPossibleTime> buildMostPossibleTimes(Map<Schedule, List<Stri
List<String> curNames = entry.getValue();

if (curNames.size() == mostPossibleCnt) {
// 이전 시간대와 병합 가능한 경우
if (canMergeWithPrevious(previousTime, schedule, curNames, category)) {
previousTime.updateEndTime(schedule.getTime());
// 종료 시간을 더해 업데이트
previousTime = previousTime.updateEndTime(schedule.getTime());
mostPossibleTimes.set(mostPossibleTimes.size() - 1, previousTime);
} else {
List<String> impossibleNames = allMembersName.stream()
.filter(name -> !curNames.contains(name))
.toList();

// 새로운 시간대를 추가
GetMostPossibleTime newTime = createMostPossibleTime(schedule, curNames, impossibleNames, category);
mostPossibleTimes.add(newTime);
previousTime = newTime;
Expand Down

0 comments on commit 4ce46db

Please sign in to comment.