feat(creator): 채널 홈 조회 정책을 추가한다

This commit is contained in:
2026-06-12 17:06:49 +09:00
parent f2c2473a47
commit 530e38c1ad
2 changed files with 154 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package kr.co.vividnext.sodalive.v2.creator.channel.domain
import kr.co.vividnext.sodalive.v2.common.domain.CreatorActivityType
import java.time.LocalDateTime
class CreatorChannelHomeQueryPolicy {
fun limitSchedules(
schedules: List<CreatorChannelSchedule>,
now: LocalDateTime
): List<CreatorChannelSchedule> {
return schedules
.filter { it.scheduledAt > now }
.sortedWith(compareBy<CreatorChannelSchedule> { it.scheduledAt }.thenBy { it.type.scheduleOrder() })
.take(3)
}
fun excludeLatestAudioContent(
audioContents: List<CreatorChannelAudioContent>,
latestAudioContentId: Long?
): List<CreatorChannelAudioContent> {
return audioContents.filter { it.audioContentId != latestAudioContentId }
}
fun markFirstAudioContent(audioContents: List<CreatorChannelAudioContent>): List<CreatorChannelAudioContent> {
val firstAudioContentId = audioContents
.minWithOrNull(compareBy<CreatorChannelAudioContent> { it.publishedAt }.thenBy { it.audioContentId })
?.audioContentId
return audioContents.map { audioContent ->
audioContent.copy(isFirstContent = audioContent.audioContentId == firstAudioContentId)
}
}
private fun CreatorActivityType.scheduleOrder(): Int {
return if (this == CreatorActivityType.LIVE) 0 else 1
}
}