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

fix : 공연 조회 기획 변경 반영 #528

Merged
merged 1 commit into from
Mar 7, 2023
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 @@ -29,7 +29,7 @@ public Slice<Event> querySliceEventsByHostIdIn(List<Long> hostIds, Pageable page
queryFactory
.selectFrom(event)
.where(hostIdIn(hostIds))
.orderBy(event.id.desc())
.orderBy(statusDesc(), createdAtDesc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
.fetch();
Expand All @@ -41,8 +41,8 @@ public Slice<Event> querySliceEventsByStatus(EventStatus status, Pageable pageab
List<Event> events =
queryFactory
.selectFrom(event)
.where(eqStatusOpen())
.orderBy(createdAtDesc())
.where(statusEq(status))
.orderBy(statusDesc(), startAtAsc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
.fetch();
Expand All @@ -54,8 +54,8 @@ public Slice<Event> querySliceEventsByKeyword(String keyword, Pageable pageable)
List<Event> events =
queryFactory
.selectFrom(event)
.where(eqStatusOpen().and(nameContains(keyword)))
.orderBy(createdAtDesc())
.where(nameContains(keyword))
.orderBy(statusDesc(), startAtAsc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize() + 1)
.fetch();
Expand All @@ -75,6 +75,10 @@ private BooleanExpression eqStatusOpen() {
return event.status.eq(OPEN);
}

private BooleanExpression statusEq(EventStatus status) {
return event.status.eq(status);
}

private BooleanExpression notEqClosed() {
return event.status.eq(CLOSED).not();
}
Expand All @@ -87,6 +91,14 @@ private OrderSpecifier<LocalDateTime> createdAtDesc() {
return event.createdAt.desc();
}

private OrderSpecifier<LocalDateTime> startAtAsc() {
return event.eventBasic.startAt.asc();
}

private OrderSpecifier<EventStatus> statusDesc() {
return event.status.desc();
}

private BooleanExpression endAtBefore(LocalDateTime time) {
DateTemplate<LocalDateTime> eventEndAtTemplate =
Expressions.dateTemplate(
Expand Down