Skip to content

Commit

Permalink
bug: LocalTime.MAX 에 .minusSeconds(1) 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomin3022 committed Jun 11, 2024
1 parent 8c40f2d commit 980d4c0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public interface ReservationRepositoryCustom {
List<Reservation> findReservationsWithDuration(Member member, LocalDateTime now, int durationStart, int durationEnd);

List<Reservation> findReservationsToday(Member member, LocalDateTime now);
Integer countTodayReservation(Member member, LocalDateTime now);

List<Reservation> findAllByRechargingRoomListAndStartTimes(List<RechargingRoom> rechargingRooms, LocalDateTime startAt, LocalDateTime endAt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public List<Reservation> findTodayFocusDeskReservationOrderByTime(Member member,
@Override
public List<Reservation> findReservationsWithDuration(Member member, LocalDateTime now, int durationStart, int durationEnd) {
LocalDateTime startAt = now.plusDays(durationStart).with(LocalTime.MIDNIGHT);
LocalDateTime endAt = now.plusDays(durationEnd).with(LocalTime.MAX);
LocalDateTime endAt = now.plusDays(durationEnd).with(LocalTime.MAX).minusSeconds(1);

return queryFactory.selectFrom(reservation)
.join(reservation.memberReservations, memberReservation)
Expand Down Expand Up @@ -149,22 +149,7 @@ private BooleanExpression nowUsing(LocalDateTime now) {

private BooleanExpression startAfterNowAndBeforeTodayMax(LocalDateTime now) {
return reservation.reservationStartDateTime.after(now)
.and(reservation.reservationStartDateTime.before(now.with(LocalTime.MAX)));
}

@Override
public Integer countTodayReservation(Member member, LocalDateTime now) {
LocalDateTime startAt = now.with(LocalTime.MIDNIGHT);
LocalDateTime endAt = now.with(LocalTime.MAX);

return Math.toIntExact(queryFactory.select(reservation.count())
.from(reservation)
.join(reservation.memberReservations, memberReservation)
.join(reservation.space, space)
.where(memberReservation.member.eq(member),
memberReservation.memberReservationStatus.eq(ReservationStatus.ACCEPTED),
reservation.reservationStartDateTime.between(startAt, endAt))
.fetchFirst());
.and(reservation.reservationStartDateTime.before(now.with(LocalTime.MAX).minusSeconds(1)));
}

@Override
Expand Down

0 comments on commit 980d4c0

Please sign in to comment.