feat(recommendation): New & Hot 전체보기 조회를 추가한다
This commit is contained in:
@@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.v2.content.recommendation.application
|
||||
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
||||
import kr.co.vividnext.sodalive.v2.content.recommendation.domain.AudioCard
|
||||
import kr.co.vividnext.sodalive.v2.content.recommendation.domain.AudioRecommendationVisibility
|
||||
import kr.co.vividnext.sodalive.v2.content.recommendation.domain.AudioRecommendations
|
||||
import kr.co.vividnext.sodalive.v2.content.recommendation.port.out.AudioRecommendationQueryPort
|
||||
@@ -29,7 +30,7 @@ class AudioRecommendationQueryService(
|
||||
val visibility = if (canViewAdultContent) AudioRecommendationVisibility.ALL else AudioRecommendationVisibility.SAFE
|
||||
val memberId = member?.id
|
||||
val newAndHotSectionType = newAndHotSectionType(visibility)
|
||||
val newAndHotSnapshots = snapshotPort.findLatestSnapshots(newAndHotSectionType, limit = NEW_AND_HOT_AUDIO_LIMIT)
|
||||
val newAndHotSnapshots = snapshotPort.findLatestSnapshots(newAndHotSectionType, limit = NEW_AND_HOT_HOME_LIMIT)
|
||||
val mostCommentedSnapshots = snapshotPort.findLatestSnapshots(
|
||||
mostCommentedSectionType(visibility),
|
||||
limit = MOST_COMMENTED_AUDIO_LIMIT
|
||||
@@ -38,7 +39,12 @@ class AudioRecommendationQueryService(
|
||||
recommendedAudioSectionType(visibility),
|
||||
limit = RECOMMENDED_AUDIO_LIMIT
|
||||
)
|
||||
val refreshedNewAndHotSnapshots = refreshMissingNewAndHotSnapshots(newAndHotSectionType, newAndHotSnapshots)
|
||||
val refreshedNewAndHotSnapshots = refreshMissingNewAndHotSnapshots(
|
||||
newAndHotSectionType,
|
||||
newAndHotSnapshots,
|
||||
offset = 0,
|
||||
limit = NEW_AND_HOT_HOME_LIMIT
|
||||
)
|
||||
|
||||
return AudioRecommendations(
|
||||
banners = queryPort.findBanners(BANNER_LIMIT, memberId, canViewAdultContent),
|
||||
@@ -66,6 +72,22 @@ class AudioRecommendationQueryService(
|
||||
)
|
||||
}
|
||||
|
||||
fun findNewAndHotAudios(member: Member, offset: Long, limit: Int): List<AudioCard> {
|
||||
val now = LocalDateTime.now()
|
||||
val canViewAdultContent = canViewAdultContent(member)
|
||||
val visibility = if (canViewAdultContent) AudioRecommendationVisibility.ALL else AudioRecommendationVisibility.SAFE
|
||||
val sectionType = newAndHotSectionType(visibility)
|
||||
val snapshots = snapshotPort.findLatestSnapshots(sectionType, offset, limit)
|
||||
val refreshedSnapshots = refreshMissingNewAndHotSnapshots(sectionType, snapshots, offset, limit)
|
||||
|
||||
return queryPort.findAudioCardsByIds(
|
||||
refreshedSnapshots.map { it.targetId },
|
||||
member.id,
|
||||
canViewAdultContent,
|
||||
now
|
||||
)
|
||||
}
|
||||
|
||||
fun resolveVisibility(member: Member?): AudioRecommendationVisibility {
|
||||
return if (canViewAdultContent(member)) AudioRecommendationVisibility.ALL else AudioRecommendationVisibility.SAFE
|
||||
}
|
||||
@@ -93,7 +115,9 @@ class AudioRecommendationQueryService(
|
||||
|
||||
private fun refreshMissingNewAndHotSnapshots(
|
||||
sectionType: RecommendedSectionType,
|
||||
snapshots: List<RecommendationSnapshotRecord>
|
||||
snapshots: List<RecommendationSnapshotRecord>,
|
||||
offset: Long,
|
||||
limit: Int
|
||||
): List<RecommendationSnapshotRecord> {
|
||||
if (snapshots.isNotEmpty()) return snapshots
|
||||
val today = LocalDate.now(KST_ZONE)
|
||||
@@ -107,7 +131,7 @@ class AudioRecommendationQueryService(
|
||||
marker.delete()
|
||||
throw ex
|
||||
}
|
||||
return snapshotPort.findLatestSnapshots(sectionType, limit = NEW_AND_HOT_AUDIO_LIMIT)
|
||||
return snapshotPort.findLatestSnapshots(sectionType, offset, limit)
|
||||
}
|
||||
|
||||
private fun newAndHotLazyRefreshMarkerKey(date: LocalDate): String {
|
||||
@@ -125,7 +149,7 @@ class AudioRecommendationQueryService(
|
||||
const val LATEST_AUDIO_LIMIT = 12
|
||||
const val FREE_AUDIO_LIMIT = 10
|
||||
const val POINT_AUDIO_LIMIT = 10
|
||||
const val NEW_AND_HOT_AUDIO_LIMIT = 12
|
||||
const val NEW_AND_HOT_HOME_LIMIT = 12
|
||||
const val MOST_COMMENTED_AUDIO_LIMIT = 5
|
||||
const val RECOMMENDED_AUDIO_LIMIT = 10
|
||||
private const val LAZY_REFRESH_MARKER_KEY_PREFIX = "audio-recommendation:new-and-hot:lazy-refresh-attempted"
|
||||
|
||||
Reference in New Issue
Block a user