Skip to content

Commit

Permalink
Merge pull request #99 from onetime-with-members/fix/#98/most
Browse files Browse the repository at this point in the history
[fix] : 가장 많이 되는 시간이 이어지지 않는 문제를 해결한다
  • Loading branch information
bbbang105 authored Oct 25, 2024
2 parents 536a482 + 4ce46db commit 0ac7d6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public static GetMostPossibleTime dateOf(Schedule schedule, List<String> possibl
);
}

public void updateEndTime(String endTime) {
new GetMostPossibleTime(
public GetMostPossibleTime updateEndTime(String endTime) {
return new GetMostPossibleTime(
this.timePoint,
this.startTime,
addThirtyMinutes(endTime),
Expand Down
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 0ac7d6a

Please sign in to comment.