test #335
| @@ -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,40 +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(1))) |  | ||||||
|             ) |  | ||||||
|             .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( | ||||||
|                 liveRoom.updatedAt.goe(LocalDateTime.now().minusWeeks(1)) |                 liveRoom.isActive.isFalse | ||||||
|                     .and( |                     .and(liveRoom.channelName.isNotNull) | ||||||
|                         Expressions.list(liveRoom.member.id, liveRoom.updatedAt) |                     .and(liveRoom.updatedAt.goe(LocalDateTime.now().minusWeeks(1))) | ||||||
|                             .`in`(subQuery) |                     .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() | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user