diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapter.kt b/src/main/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapter.kt index 9ea998f6..f4a030e1 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapter.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapter.kt @@ -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 { diff --git a/src/test/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapterTest.kt b/src/test/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapterTest.kt index 2fcceb97..5704f384 100644 --- a/src/test/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapterTest.kt +++ b/src/test/kotlin/kr/co/vividnext/sodalive/v2/recommendation/adapter/out/persistence/RecommendationSnapshotPersistenceAdapterTest.kt @@ -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(), + 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,