Skip to content

Commit

Permalink
[BugFix] - 관리자 페이지에서 문의 조회 안 되던 버그 수정했습니다.
Browse files Browse the repository at this point in the history
[BugFix] - 관리자 페이지에서 문의 조회 안 되던 버그 수정했습니다.
  • Loading branch information
fakerdeft authored May 26, 2024
2 parents 56f237f + 8ba83f1 commit 35330f0
Showing 1 changed file with 12 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import static com.coverflow.inquiry.domain.QInquiry.inquiry;

Expand Down Expand Up @@ -57,43 +55,18 @@ public Optional<Page<Inquiry>> findWithFilters(
final Pageable pageable,
final FindInquiryAdminRequest request
) {
List<Inquiry> inquiries;
long total;

CompletableFuture<List<Inquiry>> inquiriesFuture = CompletableFuture.supplyAsync(() ->
jpaQueryFactory
.selectFrom(inquiry)
.where(
toCreatedDateBetween(request.createdStartDate(), request.createdEndDate()),
eqStatus(request.status())
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(makeOrderSpecifiers(inquiry, pageable))
.fetch()
);

CompletableFuture<Long> countFuture = CompletableFuture.supplyAsync(() ->
jpaQueryFactory
.select(inquiry.count())
.from(inquiry)
.where(
toCreatedDateBetween(request.createdStartDate(), request.createdEndDate()),
eqStatus(request.status())
)
.fetchOne()
);

CompletableFuture.allOf(inquiriesFuture, countFuture).join();

try {
inquiries = inquiriesFuture.get();
total = countFuture.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}

return Optional.of(new PageImpl<>(inquiries, pageable, total));
List<Inquiry> inquiries = jpaQueryFactory
.selectFrom(inquiry)
.where(
toCreatedDateBetween(request.createdStartDate(), request.createdEndDate()),
eqStatus(request.status())
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(makeOrderSpecifiers(inquiry, pageable))
.fetch();

return Optional.of(new PageImpl<>(inquiries, pageable, inquiries.size()));
}

private BooleanExpression toContainsCreatedStartDate(final String startDate) {
Expand Down

0 comments on commit 35330f0

Please sign in to comment.