fix: 최근 종료한 라이브 API
- 차단 당한 크리에이터는 안보이도록 수정 - 20개 미만이면 재시도 처리 - 재시도 최대 횟수 3회
This commit is contained in:
parent
a3aad9d2c9
commit
d04b44c931
|
@ -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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1298,8 +1298,20 @@ class LiveRoomService(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLatestFinishedLive(): List<GetLatestFinishedLiveResponse> {
|
fun getLatestFinishedLive(member: Member?): List<GetLatestFinishedLiveResponse> {
|
||||||
return repository.getLatestFinishedLive()
|
val result = mutableListOf<GetLatestFinishedLiveResponse>()
|
||||||
|
var retry = 0L
|
||||||
|
|
||||||
|
do {
|
||||||
|
result.addAll(
|
||||||
|
repository.getLatestFinishedLive(offset = retry)
|
||||||
|
.filter {
|
||||||
|
if (member?.id != null) {
|
||||||
|
!blockMemberRepository.isBlocked(blockedMemberId = member.id!!, memberId = it.member!!.id!!)
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
.map {
|
.map {
|
||||||
GetLatestFinishedLiveResponse(
|
GetLatestFinishedLiveResponse(
|
||||||
memberId = it.member!!.id!!,
|
memberId = it.member!!.id!!,
|
||||||
|
@ -1309,5 +1321,9 @@ class LiveRoomService(
|
||||||
timeAgo = it.updatedAt!!.getTimeAgoString()
|
timeAgo = it.updatedAt!!.getTimeAgoString()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
} while (result.size < 20 && retry++ < 3)
|
||||||
|
|
||||||
|
return result.take(20)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue