Skip to content

Commit

Permalink
Api-v1.0.2-2
Browse files Browse the repository at this point in the history
Api-v1.0.2-2
  • Loading branch information
ImNM authored Mar 7, 2023
2 parents 93bb530 + bd6a2dd commit 2146799
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 2146799

Please sign in to comment.