Skip to content

Commit

Permalink
hotfix: 진행중인 이어달리기 총갯수 추가, 진행중인거 제외
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry-Cha committed May 13, 2024
1 parent f926ea6 commit 9c05fda
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private static BooleanBuilder getChallengesBooleanBuilder(ChallengeSliceRequest
.where(groupMember.member.id.eq(request.memberId()));
challengeCondition.and(challenge.id.in(subQuery));
}
challengeCondition.and(challenge.endStatus.isFalse());
return challengeCondition;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public record RelaySliceResponse(
int size,
@Schema(description = "마지막 페이지 여부")
boolean last,
@Schema(description = "이어달리기 총 갯수")
long totalCount,
@Schema(description = "이어달리기 목록")
List<RelaySimpleResponse> relays
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,20 @@ public RelaySliceResponse getRelays(RelaySliceRequest request) {
.orderBy(relay.id.desc())
.fetch();

Long totalCount = jpaQueryFactory.select(
relay.id.count()
)
.from(relay)
.where(relayCondition)
.fetchOne();

boolean hasNext = false;
if (relays.size() > pageable.getPageSize()) {
relays.remove(pageable.getPageSize());
hasNext = true;
}
return RelaySliceResponse.builder().relays(relays).page(request.page()).size(request.size())
.last(hasNext).build();
.last(hasNext).totalCount(totalCount == null ? 0 : totalCount).build();
}

private static BooleanBuilder getRelaysBooleanBuilder(RelaySliceRequest request) {
Expand All @@ -72,6 +79,7 @@ private static BooleanBuilder getRelaysBooleanBuilder(RelaySliceRequest request)
.where(relayMember.curMember.id.eq(request.memberId()));
relayCondition.and(relay.id.in(subQuery));
}
relayCondition.and(relay.endStatus.isFalse());
return relayCondition;
}

Expand Down

0 comments on commit 9c05fda

Please sign in to comment.