From fe8f62c9875bfb6295cd9c638299b3ced5179611 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Wed, 13 Nov 2024 08:45:09 -0500 Subject: [PATCH 1/5] Removed "View more" from avg views per day --- .../refresh/lists/detail/PostAverageViewsPerDayUseCase.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt index df95f358ce9d..a0e07504d6b3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt @@ -86,14 +86,16 @@ class PostAverageViewsPerDayUseCase( ) items.addAll(yearList) - if (useCaseMode == BLOCK && domainModel.yearsAverage.size > itemsToLoad) { + + // TODO we don't currently have a detail view for this + /*if (useCaseMode == BLOCK && domainModel.yearsAverage.size > itemsToLoad) { items.add( Link( text = R.string.stats_insights_view_more, navigateAction = ListItemInteraction.create(this::onLinkClick) ) ) - } + }*/ return items } From 8bacd10f29551ee680eb50f1d7ba01c70607c394 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Wed, 13 Nov 2024 08:46:56 -0500 Subject: [PATCH 2/5] Removed "View more" from avg views per day --- .../refresh/lists/detail/PostAverageViewsPerDayUseCase.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt index a0e07504d6b3..97706cae341d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt @@ -16,12 +16,10 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.Us import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseMode.VIEW_ALL import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Header -import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Link import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Title import org.wordpress.android.ui.stats.refresh.lists.sections.insights.InsightUseCaseFactory import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider -import org.wordpress.android.ui.utils.ListItemInteraction import javax.inject.Inject import javax.inject.Named @@ -103,6 +101,7 @@ class PostAverageViewsPerDayUseCase( return this != null && this.yearsAverage.isNotEmpty() && this.yearsAverage.any { it.value > 0 } } + @Suppress("unused") private fun onLinkClick() { navigateTo(ViewDayAverageStats) } From ac06e4f84a4e443c290f7de924a0110dc294908f Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Wed, 13 Nov 2024 09:19:12 -0500 Subject: [PATCH 3/5] Fixed warnings --- .../lists/detail/PostAverageViewsPerDayUseCase.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt index 97706cae341d..6fa7c1e999d1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCase.kt @@ -7,7 +7,6 @@ import org.wordpress.android.fluxc.store.StatsStore.PostDetailType import org.wordpress.android.fluxc.store.stats.PostDetailStore import org.wordpress.android.modules.BG_THREAD import org.wordpress.android.modules.UI_THREAD -import org.wordpress.android.ui.stats.refresh.NavigationTarget.ViewDayAverageStats import org.wordpress.android.ui.stats.refresh.lists.BLOCK_ITEM_COUNT import org.wordpress.android.ui.stats.refresh.lists.VIEW_ALL_ITEM_COUNT import org.wordpress.android.ui.stats.refresh.lists.detail.PostDetailMapper.ExpandedYearUiState @@ -85,12 +84,13 @@ class PostAverageViewsPerDayUseCase( items.addAll(yearList) - // TODO we don't currently have a detail view for this + // We don't currently have a detail view for this + // https://github.com/wordpress-mobile/WordPress-Android/issues/21458 /*if (useCaseMode == BLOCK && domainModel.yearsAverage.size > itemsToLoad) { items.add( Link( text = R.string.stats_insights_view_more, - navigateAction = ListItemInteraction.create(this::onLinkClick) + navigateAction = ListItemInteraction.create(navigateTo(ViewDayAverageStats)) ) ) }*/ @@ -101,11 +101,6 @@ class PostAverageViewsPerDayUseCase( return this != null && this.yearsAverage.isNotEmpty() && this.yearsAverage.any { it.value > 0 } } - @Suppress("unused") - private fun onLinkClick() { - navigateTo(ViewDayAverageStats) - } - override fun buildLoadingItem(): List { return listOf(Title(R.string.stats_detail_average_views_per_day)) } From 0c71268c2b1b4a3dae0b34f7260054e7fcac60fb Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Wed, 13 Nov 2024 10:25:30 -0500 Subject: [PATCH 4/5] Fixed failing test --- .../lists/detail/PostAverageViewsPerDayUseCaseTest.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt index 2d4e1c20a395..3f7677fc8789 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt @@ -164,7 +164,8 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() { assertMonth(this[3], "Jan", month.count.toString()) } - @Test + // See https://github.com/wordpress-mobile/WordPress-Android/pull/21457 + /*@Test fun `adds view more button when hasMore`() = test { val forced = false val data = List(10) { year } @@ -205,7 +206,7 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() { assertYear(this[2], year.year.toString(), year.value) assertLink(this[3]) } - } + }*/ @Test fun `maps error item to UI model`() = test { From f879cec1d4c51274b8d44236c526c765de5c99f2 Mon Sep 17 00:00:00 2001 From: Nick Bradbury Date: Wed, 13 Nov 2024 13:35:36 -0500 Subject: [PATCH 5/5] Fixed detekt warnings --- .../detail/PostAverageViewsPerDayUseCaseTest.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt index 3f7677fc8789..6a2d477743c9 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostAverageViewsPerDayUseCaseTest.kt @@ -31,12 +31,10 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.Us import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ExpandableItem import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Header -import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Link import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.ListItemWithIcon import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Title import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.EXPANDABLE_ITEM import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.HEADER -import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LINK import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LIST_ITEM_WITH_ICON import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.TITLE import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider @@ -206,7 +204,13 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() { assertYear(this[2], year.year.toString(), year.value) assertLink(this[3]) } - }*/ + } + + private fun assertLink(item: BlockListItem) { + assertThat(item.type).isEqualTo(LINK) + assertThat((item as Link).text).isEqualTo(R.string.stats_insights_view_more) + } + */ @Test fun `maps error item to UI model`() = test { @@ -279,11 +283,6 @@ class PostAverageViewsPerDayUseCaseTest : BaseUnitTest() { return item } - private fun assertLink(item: BlockListItem) { - assertThat(item.type).isEqualTo(LINK) - assertThat((item as Link).text).isEqualTo(R.string.stats_insights_view_more) - } - private suspend fun loadData(refresh: Boolean, forced: Boolean): UseCaseModel { var result: UseCaseModel? = null useCase.liveData.observeForever { result = it }