diff --git a/src/main/java/com/gamzabat/algohub/feature/group/ranking/repository/querydsl/CustomRankingRepositoryImpl.java b/src/main/java/com/gamzabat/algohub/feature/group/ranking/repository/querydsl/CustomRankingRepositoryImpl.java index 70fb0c96..34a15ba6 100644 --- a/src/main/java/com/gamzabat/algohub/feature/group/ranking/repository/querydsl/CustomRankingRepositoryImpl.java +++ b/src/main/java/com/gamzabat/algohub/feature/group/ranking/repository/querydsl/CustomRankingRepositoryImpl.java @@ -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; @@ -30,7 +30,7 @@ public Page findAllByStudyGroup(StudyGroup studyGroup, Pageable pageabl .orderBy(ranking.currentRank.asc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()); - JPAQuery countQuery = rankingCountQuery(); + JPAQuery countQuery = rankingCountQuery(studyGroup); return PageableExecutionUtils.getPage(query.fetch(), pageable, countQuery::fetchOne); } @@ -47,9 +47,12 @@ private JPAQuery getRankingsQuery(StudyGroup studyGroup) { .where(ranking.member.studyGroup.eq(studyGroup)); } - private JPAQuery rankingCountQuery() { + private JPAQuery 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