From 6cda73270fb36c1c099a4687cb0c2ea4abbeab90 Mon Sep 17 00:00:00 2001 From: Klaus Date: Fri, 10 Jul 2026 08:56:32 +0900 Subject: [PATCH] =?UTF-8?q?feat(home):=20=EC=9D=B8=EA=B8=B0=20=EC=BB=A4?= =?UTF-8?q?=EB=AE=A4=EB=8B=88=ED=8B=B0=20=EB=B9=88=20=EC=8A=A4=EB=83=85?= =?UTF-8?q?=EC=83=B7=20marker=EB=A5=BC=20=EC=A0=80=EC=9E=A5=ED=95=9C?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ecommendationSnapshotPersistenceAdapter.kt | 4 +- ...mendationSnapshotPersistenceAdapterTest.kt | 47 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) 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,