test #426
@@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.v2.content.ranking.application
|
|||||||
|
|
||||||
import kr.co.vividnext.sodalive.member.Member
|
import kr.co.vividnext.sodalive.member.Member
|
||||||
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
import kr.co.vividnext.sodalive.member.contentpreference.MemberContentPreferenceService
|
||||||
|
import kr.co.vividnext.sodalive.v2.common.domain.toCdnUrl
|
||||||
import kr.co.vividnext.sodalive.v2.content.ranking.domain.AudioRanking
|
import kr.co.vividnext.sodalive.v2.content.ranking.domain.AudioRanking
|
||||||
import kr.co.vividnext.sodalive.v2.content.ranking.domain.AudioRankingItem
|
import kr.co.vividnext.sodalive.v2.content.ranking.domain.AudioRankingItem
|
||||||
import kr.co.vividnext.sodalive.v2.content.ranking.domain.AudioRankingType
|
import kr.co.vividnext.sodalive.v2.content.ranking.domain.AudioRankingType
|
||||||
@@ -9,6 +10,7 @@ import kr.co.vividnext.sodalive.v2.content.ranking.port.out.AudioRankingBlockPor
|
|||||||
import kr.co.vividnext.sodalive.v2.content.ranking.port.out.AudioRankingSnapshotPort
|
import kr.co.vividnext.sodalive.v2.content.ranking.port.out.AudioRankingSnapshotPort
|
||||||
import kr.co.vividnext.sodalive.v2.content.ranking.port.out.AudioRankingSnapshotRecord
|
import kr.co.vividnext.sodalive.v2.content.ranking.port.out.AudioRankingSnapshotRecord
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.time.ZoneOffset
|
import java.time.ZoneOffset
|
||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
@@ -19,6 +21,8 @@ class AudioRankingQueryService(
|
|||||||
private val memberContentPreferenceService: MemberContentPreferenceService,
|
private val memberContentPreferenceService: MemberContentPreferenceService,
|
||||||
private val blockPort: AudioRankingBlockPort,
|
private val blockPort: AudioRankingBlockPort,
|
||||||
private val jobService: AudioRankingSnapshotJobService,
|
private val jobService: AudioRankingSnapshotJobService,
|
||||||
|
@Value("\${cloud.aws.cloud-front.host}")
|
||||||
|
private val cloudFrontHost: String,
|
||||||
private val nowProvider: () -> ZonedDateTime = { ZonedDateTime.now() }
|
private val nowProvider: () -> ZonedDateTime = { ZonedDateTime.now() }
|
||||||
) {
|
) {
|
||||||
private val log = LoggerFactory.getLogger(javaClass)
|
private val log = LoggerFactory.getLogger(javaClass)
|
||||||
@@ -105,7 +109,7 @@ class AudioRankingQueryService(
|
|||||||
rank = rank,
|
rank = rank,
|
||||||
rankChange = if (showRankChange && previousRank != null) previousRank - rank else null,
|
rankChange = if (showRankChange && previousRank != null) previousRank - rank else null,
|
||||||
isNew = showRankChange && previousRank == null,
|
isNew = showRankChange && previousRank == null,
|
||||||
coverImageUrl = coverImageUrl
|
coverImageUrl = coverImageUrl.toCdnUrl(cloudFrontHost)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,10 @@ class AudioRankingQueryServiceTest {
|
|||||||
assertEquals(listOf(1, 2, 3), result.items.map { it.rank })
|
assertEquals(listOf(1, 2, 3), result.items.map { it.rank })
|
||||||
assertEquals(listOf(1, -1, null), result.items.map { it.rankChange })
|
assertEquals(listOf(1, -1, null), result.items.map { it.rankChange })
|
||||||
assertEquals(listOf(false, false, true), result.items.map { it.isNew })
|
assertEquals(listOf(false, false, true), result.items.map { it.isNew })
|
||||||
|
assertEquals(
|
||||||
|
listOf("https://cdn.test/cover-2.png", "https://cdn.test/cover-1.png", "https://cdn.test/cover-3.png"),
|
||||||
|
result.items.map { it.coverImageUrl }
|
||||||
|
)
|
||||||
assertEquals(LocalDateTime.of(2026, 6, 8, 0, 0), snapshotPort.nowUtc)
|
assertEquals(LocalDateTime.of(2026, 6, 8, 0, 0), snapshotPort.nowUtc)
|
||||||
assertEquals(LocalDateTime.of(2026, 5, 31, 15, 0), snapshotPort.currentAggregationStartAtUtc)
|
assertEquals(LocalDateTime.of(2026, 5, 31, 15, 0), snapshotPort.currentAggregationStartAtUtc)
|
||||||
}
|
}
|
||||||
@@ -230,6 +234,7 @@ class AudioRankingQueryServiceTest {
|
|||||||
memberContentPreferenceService = memberContentPreferenceService,
|
memberContentPreferenceService = memberContentPreferenceService,
|
||||||
blockPort = blockPort,
|
blockPort = blockPort,
|
||||||
jobService = jobService,
|
jobService = jobService,
|
||||||
|
cloudFrontHost = "https://cdn.test",
|
||||||
nowProvider = { ZonedDateTime.of(2026, 6, 8, 9, 0, 0, 0, ZoneId.of("Asia/Seoul")) }
|
nowProvider = { ZonedDateTime.of(2026, 6, 8, 9, 0, 0, 0, ZoneId.of("Asia/Seoul")) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user