commit
51ce143fc2
|
@ -4,7 +4,6 @@ import com.querydsl.core.types.Projections
|
|||
import com.querydsl.core.types.dsl.CaseBuilder
|
||||
import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.core.types.dsl.NumberExpression
|
||||
import com.querydsl.jpa.JPAExpressions
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.can.use.CanUsage
|
||||
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
||||
|
@ -385,37 +384,26 @@ class LiveRoomQueryRepositoryImpl(
|
|||
}
|
||||
|
||||
override fun getLatestFinishedLive(): List<GetLatestFinishedLiveQueryResponse> {
|
||||
val liveRoom = liveRoom
|
||||
val subLiveRoom = QLiveRoom.liveRoom
|
||||
|
||||
val subQuery = JPAExpressions
|
||||
.select(subLiveRoom.member.id, subLiveRoom.updatedAt.max())
|
||||
.from(subLiveRoom)
|
||||
.where(
|
||||
subLiveRoom.isActive.isFalse
|
||||
.and(subLiveRoom.channelName.isNotNull)
|
||||
.and(subLiveRoom.member.role.eq(MemberRole.CREATOR))
|
||||
.and(subLiveRoom.member.isActive.isTrue)
|
||||
.and(subLiveRoom.updatedAt.goe(LocalDateTime.now().minusWeeks(2)))
|
||||
)
|
||||
.groupBy(subLiveRoom.member.id)
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetLatestFinishedLiveQueryResponse(
|
||||
member.id,
|
||||
member.nickname,
|
||||
member.profileImage.prepend("/").prepend(cloudFrontHost),
|
||||
liveRoom.updatedAt
|
||||
liveRoom.updatedAt.max()
|
||||
)
|
||||
)
|
||||
.from(liveRoom)
|
||||
.innerJoin(liveRoom.member, member)
|
||||
.where(
|
||||
Expressions.list(liveRoom.member.id, liveRoom.updatedAt)
|
||||
.`in`(subQuery)
|
||||
liveRoom.isActive.isFalse
|
||||
.and(liveRoom.channelName.isNotNull)
|
||||
.and(liveRoom.updatedAt.goe(LocalDateTime.now().minusWeeks(1)))
|
||||
.and(member.isActive.isTrue)
|
||||
.and(member.role.eq(MemberRole.CREATOR))
|
||||
)
|
||||
.orderBy(liveRoom.updatedAt.desc())
|
||||
.groupBy(member.id)
|
||||
.orderBy(liveRoom.updatedAt.max().desc())
|
||||
.limit(20)
|
||||
.fetch()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue