test #335

Merged
klaus merged 2 commits from test into main 2025-07-21 11:46:56 +00:00
1 changed files with 8 additions and 20 deletions

View File

@ -4,7 +4,6 @@ import com.querydsl.core.types.Projections
import com.querydsl.core.types.dsl.CaseBuilder import com.querydsl.core.types.dsl.CaseBuilder
import com.querydsl.core.types.dsl.Expressions import com.querydsl.core.types.dsl.Expressions
import com.querydsl.core.types.dsl.NumberExpression import com.querydsl.core.types.dsl.NumberExpression
import com.querydsl.jpa.JPAExpressions
import com.querydsl.jpa.impl.JPAQueryFactory import com.querydsl.jpa.impl.JPAQueryFactory
import kr.co.vividnext.sodalive.can.use.CanUsage import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
@ -385,37 +384,26 @@ class LiveRoomQueryRepositoryImpl(
} }
override fun getLatestFinishedLive(): List<GetLatestFinishedLiveQueryResponse> { 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 return queryFactory
.select( .select(
QGetLatestFinishedLiveQueryResponse( QGetLatestFinishedLiveQueryResponse(
member.id, member.id,
member.nickname, member.nickname,
member.profileImage.prepend("/").prepend(cloudFrontHost), member.profileImage.prepend("/").prepend(cloudFrontHost),
liveRoom.updatedAt liveRoom.updatedAt.max()
) )
) )
.from(liveRoom) .from(liveRoom)
.innerJoin(liveRoom.member, member) .innerJoin(liveRoom.member, member)
.where( .where(
Expressions.list(liveRoom.member.id, liveRoom.updatedAt) liveRoom.isActive.isFalse
.`in`(subQuery) .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) .limit(20)
.fetch() .fetch()
} }