Skip to content

Commit 4af85ad

Browse files
committed
refactor show query handling to simplify SliceView construction and remove unnecessary hasNext calculation
1 parent 2289a72 commit 4af85ad

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

application/src/main/java/org/mandarin/booking/app/show/ShowQueryRepository.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ boolean canScheduleOn(Long hallId, LocalDateTime startAt, LocalDateTime endAt) {
5050
}
5151

5252
SliceView<ShowResponse> fetch(@Nullable Integer page,
53-
@Nullable Integer size,
54-
@Nullable Type type,
55-
@Nullable Rating rating,
56-
@Nullable String q,
57-
@Nullable LocalDate from,
58-
@Nullable LocalDate to) {
53+
@Nullable Integer size,
54+
@Nullable Type type,
55+
@Nullable Rating rating,
56+
@Nullable String q,
57+
@Nullable LocalDate from,
58+
@Nullable LocalDate to) {
5959

6060
var builder = NullableQueryFilterBuilder.builder()
6161
.when(type, show.type::eq)
@@ -83,8 +83,6 @@ SliceView<ShowResponse> fetch(@Nullable Integer page,
8383
.limit(size + 1)
8484
.fetch();
8585

86-
boolean hasNext = results.size() > size;
87-
88-
return new SliceView<>(results, page, size, hasNext);
86+
return new SliceView<>(results, page, size);
8987
}
9088
}

internal/src/main/java/org/mandarin/booking/adapter/SliceView.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ public record SliceView<T>(
1111
@JsonProperty("size") int size,
1212
@JsonProperty("hasNext") boolean hasNext
1313
) {
14+
public SliceView(List<T> contents, int page, int size) {
15+
this(contents, page, size, contents.size() > size);
16+
}
1417
}

0 commit comments

Comments
 (0)