Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] - 관리자 페이지에서 문의 조회 안 되던 버그 수정했습니다. #291

Merged
merged 1 commit into from
May 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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