Skip to content

Commit

Permalink
Merge pull request #275 from ASAP-as-soon-as-possible/hotfix/#274
Browse files Browse the repository at this point in the history
#274 [hotfix] 회의 참여 인원 조회 쿼리 meeting id 조건 추가
  • Loading branch information
KWY0218 authored Jul 4, 2024
2 parents b95ebd7 + b08c1e0 commit 714f8a3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
public interface UserRepositoryCustom {
void updateUserIsFixedByMeeting(final Meeting meeting, final List<Long> users);

List<UserVo> findByAvailableDateAndTimeSlots(LocalDate availableDate, List<TimeSlot> timeSlots);
List<UserVo> findByAvailableDateAndTimeSlots(Long meetingId, LocalDate availableDate, List<TimeSlot> timeSlots);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public void updateUserIsFixedByMeeting(Meeting meeting, List<Long> users) {
}

@Override
public List<UserVo> findByAvailableDateAndTimeSlots(LocalDate date, List<TimeSlot> timeSlots) {
public List<UserVo> findByAvailableDateAndTimeSlots(
Long meetingId,
LocalDate date,
List<TimeSlot> timeSlots
) {
return queryFactory.select(
new QUserVo(
user.id,
Expand All @@ -40,7 +44,11 @@ public List<UserVo> findByAvailableDateAndTimeSlots(LocalDate date, List<TimeSlo
.innerJoin(timeBlock).on(timeBlockUser.timeBlock.id.eq(timeBlock.id))
.innerJoin(user).on(timeBlockUser.user.id.eq(user.id))
.innerJoin(availableDate).on(timeBlock.availableDate.id.eq(availableDate.id))
.where(availableDate.date.eq(date).and(timeBlock.timeSlot.in(timeSlots)))
.where(
availableDate.date.eq(date)
.and(availableDate.meeting.id.eq(meetingId))
.and(timeBlock.timeSlot.in(timeSlots))
)
.groupBy(user.id)
.fetch();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/asap/server/service/MeetingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public BestMeetingTimeResponseDto getBestMeetingTime(final Long meetingId, final
List<TimeBlockDto> timeBlocks = timeBlockRepository.findAllTimeBlockByMeeting(meetingId);

List<BestMeetingTimeVo> bestMeetingTimes = meetingTimeRecommendService.getBestMeetingTime(timeBlocks, meeting.getDuration(), userCount);
List<BestMeetingTimeWithUsersVo> bestMeetingTimeWithUsers = userService.getBestMeetingInUsers(bestMeetingTimes);
List<BestMeetingTimeWithUsersVo> bestMeetingTimeWithUsers = userService.getBestMeetingInUsers(meetingId, bestMeetingTimes);
return BestMeetingTimeResponseDto.of(userCount, bestMeetingTimeWithUsers);
}

Expand Down
22 changes: 16 additions & 6 deletions src/main/java/com/asap/server/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,26 @@ public HostLoginResponseDto loginByHost(
return responseDto;
}

public List<BestMeetingTimeWithUsersVo> getBestMeetingInUsers(List<BestMeetingTimeVo> bestMeetingTimes) {
public List<BestMeetingTimeWithUsersVo> getBestMeetingInUsers(
final Long meetingId,
final List<BestMeetingTimeVo> bestMeetingTimes
) {
return bestMeetingTimes.stream()
.map(this::getBestMeetingTimeInUsers)
.map(bestMeetingTime -> getBestMeetingTimeInUsers(meetingId, bestMeetingTime))
.collect(Collectors.toList());
}

private BestMeetingTimeWithUsersVo getBestMeetingTimeInUsers(final BestMeetingTimeVo bestMeetingTime) {
if (bestMeetingTime == null) return null;
List<TimeSlot> timeSlots = TimeSlot.getTimeSlots(bestMeetingTime.startTime().ordinal(), bestMeetingTime.endTime().ordinal() - 1);
List<UserVo> users = userRepository.findByAvailableDateAndTimeSlots(bestMeetingTime.date(), timeSlots);
private BestMeetingTimeWithUsersVo getBestMeetingTimeInUsers(
final Long meetingId,
final BestMeetingTimeVo bestMeetingTime
) {
if (bestMeetingTime == null) {
return null;
}
List<TimeSlot> timeSlots = TimeSlot.getTimeSlots(bestMeetingTime.startTime().ordinal(),
bestMeetingTime.endTime().ordinal() - 1);
List<UserVo> users = userRepository.findByAvailableDateAndTimeSlots(meetingId, bestMeetingTime.date(),
timeSlots);
return BestMeetingTimeWithUsersVo.of(bestMeetingTime, users);
}
}

0 comments on commit 714f8a3

Please sign in to comment.