Skip to content

Commit 603ef16

Browse files
authored
Merge pull request #14592 from woocommerce/migrate/wc-new-visitor-stats-model-to-room
[WellSQL Migration] Migrate `WCNewVisitorStatsModel` to Room
2 parents d682edd + 2e11297 commit 603ef16

File tree

16 files changed

+4576
-444
lines changed

16 files changed

+4576
-444
lines changed

WooCommerce-Wear/src/main/java/com/woocommerce/android/wear/ui/stats/datasource/StatsRepository.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class StatsRepository @Inject constructor(
101101
result.granularity,
102102
result.quantity,
103103
result.date,
104-
result.isCustomField
105104
).let {
106105
Result.success(it.values.sum())
107106
}

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/data/StatsRepository.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ class StatsRepository @Inject constructor(
154154
result.granularity,
155155
result.quantity,
156156
result.date,
157-
result.isCustomField
158157
)
159158
}
160159
Result.success(visitorStats)

WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/data/StatsRepositoryTests.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ class StatsRepositoryTests : BaseUnitTest() {
6868
fun `when visitors and revenue requests succeed then a success response is returned containing both value`() =
6969
testBlocking {
7070
val granularity = WCStatsStore.StatsGranularity.DAYS
71+
val quantity = "5"
7172
val startDate = "2024-01-25 00:00:00"
7273
val endDate = "2024-01-25 23:59:59"
7374
val visitorStatsResponse = WCStatsStore.OnWCStatsChanged(
74-
rowsAffected = 2,
7575
granularity = granularity,
76-
quantity = "5",
76+
quantity = quantity,
7777
date = startDate
7878
)
7979

@@ -87,6 +87,8 @@ class StatsRepositoryTests : BaseUnitTest() {
8787
whenever(selectedSite.get()).thenReturn(defaultSiteModel)
8888
whenever(wooCommerceStore.getSiteSettings(any())).thenReturn(null)
8989
whenever(wcStatsStore.fetchNewVisitorStats(any())).thenReturn(visitorStatsResponse)
90+
whenever(wcStatsStore.getNewVisitorStats(defaultSiteModel, granularity, quantity, startDate))
91+
.thenReturn(emptyMap())
9092
whenever(wcStatsStore.fetchRevenueStats(any())).thenReturn(revenueStatsResponse)
9193
whenever(wcStatsStore.getRawRevenueStats(eq(defaultSiteModel), eq(granularity), eq(startDate), eq(endDate)))
9294
.thenReturn(WCRevenueStatsModel())
@@ -111,7 +113,7 @@ class StatsRepositoryTests : BaseUnitTest() {
111113
val granularity = WCStatsStore.StatsGranularity.DAYS
112114
val startDate = "2024-01-25 00:00:00"
113115
val endDate = "2024-01-25 23:59:59"
114-
val visitorStatsResponse = WCStatsStore.OnWCStatsChanged(0, granularity).also {
116+
val visitorStatsResponse = WCStatsStore.OnWCStatsChanged(granularity).also {
115117
it.error = WCStatsStore.OrderStatsError()
116118
it.causeOfChange = WCStatsAction.FETCH_NEW_VISITOR_STATS
117119
}
@@ -150,7 +152,6 @@ class StatsRepositoryTests : BaseUnitTest() {
150152
val granularity = WCStatsStore.StatsGranularity.DAYS
151153
val startDate = "2024-01-25 00:00:00"
152154
val visitorStatsResponse = WCStatsStore.OnWCStatsChanged(
153-
rowsAffected = 2,
154155
granularity = granularity,
155156
quantity = "5",
156157
date = startDate

config/detekt/baseline.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,21 +2271,6 @@
22712271
<ID>UnitTestNamingRule:WCShippingLabelStoreTest.kt$WCShippingLabelStoreTest$@Test fun `verify shipping address`()</ID>
22722272
<ID>UnitTestNamingRule:WCStatsSqlUtilsTest.kt$WCStatsSqlUtilsTest$@Test @Suppress("LongMethod") fun testGetRawRevenueStatsForSiteAndUnit()</ID>
22732273
<ID>UnitTestNamingRule:WCStatsSqlUtilsTest.kt$WCStatsSqlUtilsTest$@Test @Suppress("LongMethod") fun testSimpleInsertionAndRetrievalOfRevenueStats()</ID>
2274-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Suppress("LongMethod") @Test fun testGetQuantityForMonths()</ID>
2275-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Suppress("LongMethod") @Test fun testGetQuantityForWeeks()</ID>
2276-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Suppress("LongMethod") @Test fun testGetQuantityForYears()</ID>
2277-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test @Suppress("LongMethod") fun testGetRevenueAndOrderStatsForSite()</ID>
2278-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test @Suppress("LongMethod") fun testGetVisitorStatsForCurrentDayGranularity()</ID>
2279-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test @Suppress("LongMethod") fun testGetVisitorStatsForThisWeekGranularity()</ID>
2280-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testFailedFetchingVisitorSummaryStats()</ID>
2281-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testFetchBundlesErrorResponse()</ID>
2282-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testFetchBundlesNullResponse()</ID>
2283-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testFetchBundlesSuccessResponse()</ID>
2284-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testFetchCurrentDayRevenueStatsDate()</ID>
2285-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testFetchCurrentDayRevenueStatsDateSpecificEndDate()</ID>
2286-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testGetNewVisitorStatsWithInvalidData()</ID>
2287-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testGetQuantityForDays()</ID>
2288-
<ID>UnitTestNamingRule:WCStatsStoreTest.kt$WCStatsStoreTest$@Test fun testSuccessfulFetchingVisitorSummaryStats()</ID>
22892274
<ID>UnitTestNamingRule:WCTaxStoreTest.kt$WCTaxStoreTest$@Test fun `get stored tax class list for site`()</ID>
22902275
<ID>UnitTestNamingRule:WCUserStoreTest.kt$WCUserStoreTest$@Test fun `fetch user role`()</ID>
22912276
<ID>UnitTestNamingRule:WCUserStoreTest.kt$WCUserStoreTest$@Test fun `get user role from db`()</ID>

0 commit comments

Comments
 (0)