Skip to content

Commit

Permalink
Fix. 일자 판단 로직 오류 수정
Browse files Browse the repository at this point in the history
checkInDate ~ checkInDate
  • Loading branch information
Miensoap committed Jun 26, 2024
1 parent 055e210 commit 24dc40f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BE/src/main/java/team07/airbnb/entity/ProductEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ProductEntity reopen(BookingEntity booking) {
}

public boolean isDateInRange(LocalDate start, LocalDate end) {
return this.date.isAfter(start) && this.date.isBefore(end.plusDays(1L));
return !this.date.isBefore(start) && this.date.isBefore(end.plusDays(1L));
}

private void checkBookingEquality(BookingEntity booking) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public List<ProductListResponse> findWithFilter(AccommodationFilterDTO filter) {
)
).toList();

log.info(accommodations.toString());

if (filter.minPrice() != null){
accommodations = accommodations.stream()
.filter(accommodation -> accommodation.price() >= filter.minPrice())
Expand All @@ -61,8 +59,6 @@ public List<ProductListResponse> findWithFilter(AccommodationFilterDTO filter) {
.toList();
}

log.info("리턴 직전 = " + accommodations.toString());

return accommodations;
}

Expand All @@ -87,9 +83,10 @@ private Stream<List<ProductEntity>> getFilteredStream(AccommodationFilterDTO fil
private int getAveragePriceForDateRange(List<ProductEntity> openProducts, LocalDate checkInDate, LocalDate checkOutDate) {
if (checkInDate != null && checkOutDate != null) {
openProducts = openProducts.stream()
.filter(product -> product.isDateInRange(checkInDate, checkInDate))
.filter(product -> product.isDateInRange(checkInDate, checkOutDate))
.toList();
}

return (int) openProducts.stream()
.mapToInt(ProductEntity::getPrice)
.average()
Expand Down

0 comments on commit 24dc40f

Please sign in to comment.