feat(home): 인기 커뮤니티 빈 스냅샷 marker를 저장한다

This commit is contained in:
2026-07-10 08:56:32 +09:00
parent ea331ce66f
commit 6cda73270f
2 changed files with 50 additions and 1 deletions

View File

@@ -84,7 +84,9 @@ class RecommendationSnapshotPersistenceAdapter(
}
private fun supportsEmptySnapshotMarker(sectionType: RecommendedSectionType): Boolean {
return sectionType == RecommendedSectionType.AI_CHARACTER || sectionType == RecommendedSectionType.CHEER_CREATOR
return sectionType == RecommendedSectionType.AI_CHARACTER ||
sectionType == RecommendedSectionType.CHEER_CREATOR ||
sectionType == RecommendedSectionType.POPULAR_COMMUNITY
}
companion object {

View File

@@ -217,6 +217,25 @@ class RecommendationSnapshotPersistenceAdapterTest @Autowired constructor(
)
}
@Test
fun shouldSavePopularCommunityEmptySnapshotMarkerWhenReplacingWithEmptySnapshots() {
val snapshotAt = LocalDateTime.of(2026, 5, 29, 23, 59, 59)
adapter.replaceSnapshots(RecommendedSectionType.POPULAR_COMMUNITY, snapshotAt, emptyList())
assertEquals(
emptyList<RecommendationSnapshotRecord>(),
adapter.findSnapshots(RecommendedSectionType.POPULAR_COMMUNITY, snapshotAt)
)
assertEquals(true, adapter.existsSnapshot(RecommendedSectionType.POPULAR_COMMUNITY, snapshotAt))
assertEquals(
listOf(0L),
repository.findAll()
.filter { it.sectionType == RecommendedSectionType.POPULAR_COMMUNITY }
.map { it.targetId }
)
}
@Test
fun shouldReplaceCheerCreatorEmptyMarkerWithRealSnapshots() {
val snapshotAt = LocalDateTime.of(2026, 5, 29, 23, 59, 59)
@@ -245,6 +264,34 @@ class RecommendationSnapshotPersistenceAdapterTest @Autowired constructor(
)
}
@Test
fun shouldReplacePopularCommunityEmptyMarkerWithRealSnapshots() {
val snapshotAt = LocalDateTime.of(2026, 5, 29, 23, 59, 59)
adapter.replaceSnapshots(RecommendedSectionType.POPULAR_COMMUNITY, snapshotAt, emptyList())
adapter.replaceSnapshots(
RecommendedSectionType.POPULAR_COMMUNITY,
snapshotAt,
listOf(
RecommendationSnapshotRecord(
sectionType = RecommendedSectionType.POPULAR_COMMUNITY,
targetId = 19L,
score = 190.0,
snapshotAt = snapshotAt,
randomTieBreaker = 0.9
)
)
)
assertEquals(listOf(19L), adapter.findSnapshots(RecommendedSectionType.POPULAR_COMMUNITY, snapshotAt).map { it.targetId })
assertEquals(
listOf(19L),
repository.findAll()
.filter { it.sectionType == RecommendedSectionType.POPULAR_COMMUNITY }
.map { it.targetId }
)
}
private fun snapshot(
sectionType: RecommendedSectionType,
targetId: Long,