fix: 최근 종료한 라이브 API 오류 수정

- SQLSyntaxErrorException 오류수정
- select 값에 집계쿼리를 넣어서 해결
This commit is contained in:
Klaus 2025-07-18 15:46:20 +09:00
parent d04b44c931
commit a849d00c7f
3 changed files with 34 additions and 13 deletions

View File

@ -1,9 +1,29 @@
package kr.co.vividnext.sodalive.live.room
import com.querydsl.core.annotations.QueryProjection
import kr.co.vividnext.sodalive.extensions.getTimeAgoString
import java.time.LocalDateTime
data class GetLatestFinishedLiveQueryResponse @QueryProjection constructor(
val memberId: Long,
val nickname: String,
val profileImageUrl: String,
val title: String,
val updatedAt: LocalDateTime
)
data class GetLatestFinishedLiveResponse(
val memberId: Long,
val nickname: String,
val profileImageUrl: String,
val title: String,
val timeAgo: String
)
) {
constructor(response: GetLatestFinishedLiveQueryResponse) : this(
response.memberId,
response.nickname,
response.profileImageUrl,
response.title,
response.updatedAt.getTimeAgoString()
)
}

View File

@ -60,7 +60,7 @@ interface LiveRoomQueryRepository {
fun getTotalHeartCount(roomId: Long): Int?
fun getLiveRoomCreatorId(roomId: Long): Long?
fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem>
fun getLatestFinishedLive(offset: Long): List<LiveRoom>
fun getLatestFinishedLive(offset: Long): List<GetLatestFinishedLiveQueryResponse>
}
class LiveRoomQueryRepositoryImpl(
@ -382,9 +382,17 @@ class LiveRoomQueryRepositoryImpl(
.fetch()
}
override fun getLatestFinishedLive(offset: Long): List<LiveRoom> {
override fun getLatestFinishedLive(offset: Long): List<GetLatestFinishedLiveQueryResponse> {
return queryFactory
.selectFrom(liveRoom)
.select(
QGetLatestFinishedLiveQueryResponse(
member.id,
member.nickname,
member.profileImage.prepend("/").prepend(cloudFrontHost),
liveRoom.title,
liveRoom.updatedAt.max()
)
)
.innerJoin(liveRoom.member, member)
.where(
liveRoom.isActive.isFalse

View File

@ -19,7 +19,6 @@ import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.explorer.ExplorerQueryRepository
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.extensions.getTimeAgoString
import kr.co.vividnext.sodalive.fcm.FcmEvent
import kr.co.vividnext.sodalive.fcm.FcmEventType
import kr.co.vividnext.sodalive.live.reservation.LiveReservationRepository
@ -1307,19 +1306,13 @@ class LiveRoomService(
repository.getLatestFinishedLive(offset = retry)
.filter {
if (member?.id != null) {
!blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!)
!blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.memberId)
} else {
true
}
}
.map {
GetLatestFinishedLiveResponse(
memberId = it.member!!.id!!,
nickname = it.member!!.nickname,
profileImageUrl = "$cloudFrontHost/${it.member!!.profileImage}",
title = it.title,
timeAgo = it.updatedAt!!.getTimeAgoString()
)
GetLatestFinishedLiveResponse(response = it)
}
)
} while (result.size < 20 && retry++ < 3)