Skip to content

Commit a018c7e

Browse files
authored
Merge pull request #153 from team-gogo/update/rank-query-covering-index
[stage] 랭킹 조회 쿼리 커버링 인덱스 적용
2 parents c157454 + ec02209 commit a018c7e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/main/kotlin/gogo/gogostage/domain/stage/root/application/dto/StageDto.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ data class QueryMyStageInfoDto(
170170
val isMaintaining: Boolean
171171
)
172172

173+
data class StageParticipantPointOnly(
174+
val id: Long,
175+
val studentId: Long,
176+
val point: Long
177+
)
178+
173179
data class StageParticipantPointRankDto(
174180
val info: PageDto,
175181
val rank: List<PointRankDto>

src/main/kotlin/gogo/gogostage/domain/stage/root/persistence/StageCustomRepositoryImpl.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package gogo.gogostage.domain.stage.root.persistence
22

33
import com.querydsl.core.BooleanBuilder
4+
import com.querydsl.core.types.Projections
45
import com.querydsl.jpa.impl.JPAQueryFactory
56
import gogo.gogostage.domain.stage.participant.root.persistence.QStageParticipant.stageParticipant
67
import gogo.gogostage.domain.stage.root.application.dto.PageDto
78
import gogo.gogostage.domain.stage.root.application.dto.PointRankDto
9+
import gogo.gogostage.domain.stage.root.application.dto.StageParticipantPointOnly
810
import gogo.gogostage.domain.stage.root.application.dto.StageParticipantPointRankDto
911
import gogo.gogostage.global.internal.student.api.StudentApi
1012
import org.springframework.data.domain.Pageable
@@ -21,7 +23,16 @@ class StageCustomRepositoryImpl(
2123

2224
predicate.and(stageParticipant.stage.id.eq(stage.id))
2325

24-
val studentParticipants = queryFactory.selectFrom(stageParticipant)
26+
val studentParticipants = queryFactory
27+
.select(
28+
Projections.constructor(
29+
StageParticipantPointOnly::class.java,
30+
stageParticipant.id,
31+
stageParticipant.studentId,
32+
stageParticipant.point
33+
)
34+
)
35+
.from(stageParticipant)
2536
.where(predicate)
2637
.orderBy(stageParticipant.point.desc())
2738
.offset(pageable.offset)
@@ -59,4 +70,4 @@ class StageCustomRepositoryImpl(
5970

6071
}
6172

62-
}
73+
}

0 commit comments

Comments
 (0)