From 8ba83f1e3297153e902d5a24f54d86e8a2b45420 Mon Sep 17 00:00:00 2001 From: fakerdeft Date: Sun, 26 May 2024 20:02:26 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20=EB=AC=B8=EC=9D=98=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=95=88=20=EB=90=98=EB=8D=98=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=ED=96=88=EC=8A=B5=EB=8B=88?= =?UTF-8?q?=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InquiryCustomRepositoryImpl.java | 51 +++++-------------- 1 file changed, 12 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/coverflow/inquiry/infrastructure/InquiryCustomRepositoryImpl.java b/src/main/java/com/coverflow/inquiry/infrastructure/InquiryCustomRepositoryImpl.java index c0bb43db..0b1e321a 100644 --- a/src/main/java/com/coverflow/inquiry/infrastructure/InquiryCustomRepositoryImpl.java +++ b/src/main/java/com/coverflow/inquiry/infrastructure/InquiryCustomRepositoryImpl.java @@ -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; @@ -57,43 +55,18 @@ public Optional> findWithFilters( final Pageable pageable, final FindInquiryAdminRequest request ) { - List inquiries; - long total; - - CompletableFuture> 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 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 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) {