fix: 최근 종료한 라이브 API

- 차단 당한 크리에이터는 안보이도록 수정
- 20개 미만이면 재시도 처리
- 재시도 최대 횟수 3회
This commit is contained in:
Klaus 2025-07-18 14:40:16 +09:00
parent a3aad9d2c9
commit d04b44c931
3 changed files with 35 additions and 14 deletions

View File

@ -293,5 +293,9 @@ class LiveRoomController(
} }
@GetMapping("/latest-finished-live") @GetMapping("/latest-finished-live")
fun getLatestFinishedLive() = run { ApiResponse.ok(service.getLatestFinishedLive()) } fun getLatestFinishedLive(
@AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
) = run {
ApiResponse.ok(service.getLatestFinishedLive(member))
}
} }

View File

@ -60,7 +60,7 @@ interface LiveRoomQueryRepository {
fun getTotalHeartCount(roomId: Long): Int? fun getTotalHeartCount(roomId: Long): Int?
fun getLiveRoomCreatorId(roomId: Long): Long? fun getLiveRoomCreatorId(roomId: Long): Long?
fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem> fun getHeartList(roomId: Long): List<GetLiveRoomHeartListItem>
fun getLatestFinishedLive(): List<LiveRoom> fun getLatestFinishedLive(offset: Long): List<LiveRoom>
} }
class LiveRoomQueryRepositoryImpl( class LiveRoomQueryRepositoryImpl(
@ -382,7 +382,7 @@ class LiveRoomQueryRepositoryImpl(
.fetch() .fetch()
} }
override fun getLatestFinishedLive(): List<LiveRoom> { override fun getLatestFinishedLive(offset: Long): List<LiveRoom> {
return queryFactory return queryFactory
.selectFrom(liveRoom) .selectFrom(liveRoom)
.innerJoin(liveRoom.member, member) .innerJoin(liveRoom.member, member)
@ -392,6 +392,7 @@ class LiveRoomQueryRepositoryImpl(
) )
.groupBy(liveRoom.member.id) .groupBy(liveRoom.member.id)
.orderBy(liveRoom.updatedAt.max().desc()) .orderBy(liveRoom.updatedAt.max().desc())
.offset(offset)
.limit(20) .limit(20)
.fetch() .fetch()
} }

View File

@ -1298,16 +1298,32 @@ class LiveRoomService(
) )
} }
fun getLatestFinishedLive(): List<GetLatestFinishedLiveResponse> { fun getLatestFinishedLive(member: Member?): List<GetLatestFinishedLiveResponse> {
return repository.getLatestFinishedLive() val result = mutableListOf<GetLatestFinishedLiveResponse>()
.map { var retry = 0L
GetLatestFinishedLiveResponse(
memberId = it.member!!.id!!, do {
nickname = it.member!!.nickname, result.addAll(
profileImageUrl = "$cloudFrontHost/${it.member!!.profileImage}", repository.getLatestFinishedLive(offset = retry)
title = it.title, .filter {
timeAgo = it.updatedAt!!.getTimeAgoString() if (member?.id != null) {
) !blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!)
} } else {
true
}
}
.map {
GetLatestFinishedLiveResponse(
memberId = it.member!!.id!!,
nickname = it.member!!.nickname,
profileImageUrl = "$cloudFrontHost/${it.member!!.profileImage}",
title = it.title,
timeAgo = it.updatedAt!!.getTimeAgoString()
)
}
)
} while (result.size < 20 && retry++ < 3)
return result.take(20)
} }
} }