fix(recommendation): 홈 추천 query offset 범위를 확장한다
This commit is contained in:
@@ -51,7 +51,7 @@ class DefaultHomeRecommendationQueryRepository(
|
|||||||
private val entityManager: EntityManager
|
private val entityManager: EntityManager
|
||||||
) : HomeRecommendationQueryRepository {
|
) : HomeRecommendationQueryRepository {
|
||||||
override fun findLiveRecommendations(
|
override fun findLiveRecommendations(
|
||||||
offset: Int,
|
offset: Long,
|
||||||
limit: Int,
|
limit: Int,
|
||||||
memberId: Long?,
|
memberId: Long?,
|
||||||
includeAdultLives: Boolean
|
includeAdultLives: Boolean
|
||||||
@@ -79,7 +79,7 @@ class DefaultHomeRecommendationQueryRepository(
|
|||||||
member.isActive.isTrue
|
member.isActive.isTrue
|
||||||
)
|
)
|
||||||
.orderBy(liveRoom.beginDateTime.desc(), liveRoom.id.desc())
|
.orderBy(liveRoom.beginDateTime.desc(), liveRoom.id.desc())
|
||||||
.offset(offset.toLong())
|
.offset(offset)
|
||||||
.limit(limit.toLong())
|
.limit(limit.toLong())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
@@ -211,7 +211,7 @@ class DefaultHomeRecommendationQueryRepository(
|
|||||||
|
|
||||||
override fun findRecentDebutCreators(
|
override fun findRecentDebutCreators(
|
||||||
now: LocalDateTime,
|
now: LocalDateTime,
|
||||||
offset: Int,
|
offset: Long,
|
||||||
limit: Int,
|
limit: Int,
|
||||||
memberId: Long?,
|
memberId: Long?,
|
||||||
includeAdultContents: Boolean
|
includeAdultContents: Boolean
|
||||||
@@ -355,7 +355,7 @@ class DefaultHomeRecommendationQueryRepository(
|
|||||||
|
|
||||||
override fun findFirstAudioContents(
|
override fun findFirstAudioContents(
|
||||||
now: LocalDateTime,
|
now: LocalDateTime,
|
||||||
offset: Int,
|
offset: Long,
|
||||||
limit: Int,
|
limit: Int,
|
||||||
memberId: Long?,
|
memberId: Long?,
|
||||||
includeAdultContents: Boolean
|
includeAdultContents: Boolean
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.time.LocalDateTime
|
|||||||
|
|
||||||
interface HomeRecommendationQueryPort {
|
interface HomeRecommendationQueryPort {
|
||||||
fun findLiveRecommendations(
|
fun findLiveRecommendations(
|
||||||
offset: Int = 0,
|
offset: Long = 0,
|
||||||
limit: Int,
|
limit: Int,
|
||||||
memberId: Long? = null,
|
memberId: Long? = null,
|
||||||
includeAdultLives: Boolean = false
|
includeAdultLives: Boolean = false
|
||||||
@@ -24,7 +24,7 @@ interface HomeRecommendationQueryPort {
|
|||||||
|
|
||||||
fun findRecentDebutCreators(
|
fun findRecentDebutCreators(
|
||||||
now: LocalDateTime,
|
now: LocalDateTime,
|
||||||
offset: Int = 0,
|
offset: Long = 0,
|
||||||
limit: Int,
|
limit: Int,
|
||||||
memberId: Long? = null,
|
memberId: Long? = null,
|
||||||
includeAdultContents: Boolean = false
|
includeAdultContents: Boolean = false
|
||||||
@@ -32,7 +32,7 @@ interface HomeRecommendationQueryPort {
|
|||||||
|
|
||||||
fun findFirstAudioContents(
|
fun findFirstAudioContents(
|
||||||
now: LocalDateTime,
|
now: LocalDateTime,
|
||||||
offset: Int = 0,
|
offset: Long = 0,
|
||||||
limit: Int,
|
limit: Int,
|
||||||
memberId: Long? = null,
|
memberId: Long? = null,
|
||||||
includeAdultContents: Boolean = false
|
includeAdultContents: Boolean = false
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ class DefaultHomeRecommendationQueryRepositoryTest @Autowired constructor(
|
|||||||
val oldest = saveLiveRoom(creator, baseAt, channelName = "paged-live-oldest", isAdult = false)
|
val oldest = saveLiveRoom(creator, baseAt, channelName = "paged-live-oldest", isAdult = false)
|
||||||
flushAndClear()
|
flushAndClear()
|
||||||
|
|
||||||
val page0 = repository.findLiveRecommendations(offset = 0, limit = 3, includeAdultLives = false)
|
val page0 = repository.findLiveRecommendations(offset = 0L, limit = 3, includeAdultLives = false)
|
||||||
val page1 = repository.findLiveRecommendations(offset = 2, limit = 3, includeAdultLives = false)
|
val page1 = repository.findLiveRecommendations(offset = 2L, limit = 3, includeAdultLives = false)
|
||||||
|
|
||||||
assertEquals(listOf(newest.id, middle.id, oldest.id), page0.map { it.liveRoomId })
|
assertEquals(listOf(newest.id, middle.id, oldest.id), page0.map { it.liveRoomId })
|
||||||
assertEquals(listOf(oldest.id), page1.map { it.liveRoomId })
|
assertEquals(listOf(oldest.id), page1.map { it.liveRoomId })
|
||||||
@@ -1032,8 +1032,8 @@ class DefaultHomeRecommendationQueryRepositoryTest @Autowired constructor(
|
|||||||
updateCreatedAt("AudioContentLike", like.id!!, now.minusHours(1))
|
updateCreatedAt("AudioContentLike", like.id!!, now.minusHours(1))
|
||||||
flushAndClear()
|
flushAndClear()
|
||||||
|
|
||||||
val page0 = repository.findRecentDebutCreators(now, offset = 0, limit = 2, includeAdultContents = false)
|
val page0 = repository.findRecentDebutCreators(now, offset = 0L, limit = 2, includeAdultContents = false)
|
||||||
val page1 = repository.findRecentDebutCreators(now, offset = 1, limit = 2, includeAdultContents = false)
|
val page1 = repository.findRecentDebutCreators(now, offset = 1L, limit = 2, includeAdultContents = false)
|
||||||
|
|
||||||
assertEquals(listOf(normalNewest.id, normalOldest.id), page0.map { it.creatorId })
|
assertEquals(listOf(normalNewest.id, normalOldest.id), page0.map { it.creatorId })
|
||||||
assertEquals(listOf(normalOldest.id), page1.map { it.creatorId })
|
assertEquals(listOf(normalOldest.id), page1.map { it.creatorId })
|
||||||
@@ -1071,9 +1071,9 @@ class DefaultHomeRecommendationQueryRepositoryTest @Autowired constructor(
|
|||||||
saveAudioContent(creator3, now.minusDays(5), isActive = true)
|
saveAudioContent(creator3, now.minusDays(5), isActive = true)
|
||||||
flushAndClear()
|
flushAndClear()
|
||||||
|
|
||||||
val page0 = repository.findRecentDebutCreators(now, offset = 0, limit = 1, includeAdultContents = false)
|
val page0 = repository.findRecentDebutCreators(now, offset = 0L, limit = 1, includeAdultContents = false)
|
||||||
val page1 = repository.findRecentDebutCreators(now, offset = 1, limit = 1, includeAdultContents = false)
|
val page1 = repository.findRecentDebutCreators(now, offset = 1L, limit = 1, includeAdultContents = false)
|
||||||
val page2 = repository.findRecentDebutCreators(now, offset = 2, limit = 1, includeAdultContents = false)
|
val page2 = repository.findRecentDebutCreators(now, offset = 2L, limit = 1, includeAdultContents = false)
|
||||||
|
|
||||||
val pagedCreatorIds = (page0 + page1 + page2).map { it.creatorId }
|
val pagedCreatorIds = (page0 + page1 + page2).map { it.creatorId }
|
||||||
assertEquals(setOf(creator1.id, creator2.id, creator3.id), pagedCreatorIds.toSet())
|
assertEquals(setOf(creator1.id, creator2.id, creator3.id), pagedCreatorIds.toSet())
|
||||||
@@ -1157,8 +1157,8 @@ class DefaultHomeRecommendationQueryRepositoryTest @Autowired constructor(
|
|||||||
val oldest = saveAudioContent(oldestCreator, now.minusDays(21), isActive = true, isAdult = false)
|
val oldest = saveAudioContent(oldestCreator, now.minusDays(21), isActive = true, isAdult = false)
|
||||||
flushAndClear()
|
flushAndClear()
|
||||||
|
|
||||||
val page0 = repository.findFirstAudioContents(now, offset = 0, limit = 2, includeAdultContents = false)
|
val page0 = repository.findFirstAudioContents(now, offset = 0L, limit = 2, includeAdultContents = false)
|
||||||
val page1 = repository.findFirstAudioContents(now, offset = 1, limit = 2, includeAdultContents = false)
|
val page1 = repository.findFirstAudioContents(now, offset = 1L, limit = 2, includeAdultContents = false)
|
||||||
|
|
||||||
assertEquals(listOf(newest.id, oldest.id), page0.map { it.contentId })
|
assertEquals(listOf(newest.id, oldest.id), page0.map { it.contentId })
|
||||||
assertEquals(listOf(oldest.id), page1.map { it.contentId })
|
assertEquals(listOf(oldest.id), page1.map { it.contentId })
|
||||||
@@ -1196,9 +1196,9 @@ class DefaultHomeRecommendationQueryRepositoryTest @Autowired constructor(
|
|||||||
val content3 = saveAudioContent(creator3, now.minusDays(5), isActive = true)
|
val content3 = saveAudioContent(creator3, now.minusDays(5), isActive = true)
|
||||||
flushAndClear()
|
flushAndClear()
|
||||||
|
|
||||||
val page0 = repository.findFirstAudioContents(now, offset = 0, limit = 1, includeAdultContents = false)
|
val page0 = repository.findFirstAudioContents(now, offset = 0L, limit = 1, includeAdultContents = false)
|
||||||
val page1 = repository.findFirstAudioContents(now, offset = 1, limit = 1, includeAdultContents = false)
|
val page1 = repository.findFirstAudioContents(now, offset = 1L, limit = 1, includeAdultContents = false)
|
||||||
val page2 = repository.findFirstAudioContents(now, offset = 2, limit = 1, includeAdultContents = false)
|
val page2 = repository.findFirstAudioContents(now, offset = 2L, limit = 1, includeAdultContents = false)
|
||||||
|
|
||||||
val pagedContentIds = (page0 + page1 + page2).map { it.contentId }
|
val pagedContentIds = (page0 + page1 + page2).map { it.contentId }
|
||||||
assertEquals(setOf(content1.id, content2.id, content3.id), pagedContentIds.toSet())
|
assertEquals(setOf(content1.id, content2.id, content3.id), pagedContentIds.toSet())
|
||||||
|
|||||||
Reference in New Issue
Block a user