Skip to content

Commit

Permalink
fix : 랭킹 totalPage 오류 해결 (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
rladmstn authored Dec 8, 2024
1 parent dae2f9e commit e2d47a4
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import com.gamzabat.algohub.feature.group.ranking.domain.Ranking;
import com.gamzabat.algohub.feature.group.studygroup.domain.StudyGroup;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;

import lombok.AllArgsConstructor;
Expand All @@ -30,7 +30,7 @@ public Page<Ranking> findAllByStudyGroup(StudyGroup studyGroup, Pageable pageabl
.orderBy(ranking.currentRank.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize());
JPAQuery<Long> countQuery = rankingCountQuery();
JPAQuery<Long> countQuery = rankingCountQuery(studyGroup);

return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchOne);
}
Expand All @@ -47,9 +47,12 @@ private JPAQuery<Ranking> getRankingsQuery(StudyGroup studyGroup) {
.where(ranking.member.studyGroup.eq(studyGroup));
}

private JPAQuery<Long> rankingCountQuery() {
private JPAQuery<Long> rankingCountQuery(StudyGroup studyGroup) {
return queryFactory.select(ranking.count())
.from(ranking);
.from(ranking)
.join(ranking.member, groupMember)
.join(groupMember.user, user)
.where(ranking.member.studyGroup.eq(studyGroup));
}

@Override
Expand Down

0 comments on commit e2d47a4

Please sign in to comment.