Skip to content

Commit

Permalink
fix : 공연 조회 기획 변경 반영 (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
gengminy authored Mar 7, 2023
1 parent 0b2f291 commit bd6a2dd
Showing 1 changed file with 17 additions and 5 deletions.
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

0 comments on commit bd6a2dd

Please sign in to comment.