woocommerce-android
woocommerce-android copied to clipboard
Feature/6618 limit stats refresh
⚠️ Do not merge until FluxC changes are merged
Part of: #6618
Description
wc-analytics endpoint is one of the slowest endpoints we hit from the app, and is one that we hit a lot. We fetch site stats and top performers every time we open My Store tab and when we change between tabs. This translates into the "slow/endless loading" perception of the app. This PR alongside changes applied in this other PR in woocommerce-android aim to reduce that loading "slowness" for top performer products data with the following changes:
- Migrate top performers cache to Room to easily expose an observable
- Simplify top performers cached model to avoid having to parse multiple JSON or query different sql tables to load top performers from cache
- Invalidate top performers cache when a new order is placed
- Invalidate top performers cache after 1h. Maybe this is to often? please share your thoughs
Finally, I update all broken unit tests, remove some that did not apply anymore and added a couple more.
Testing instructions
Log into the app and check the following:
- Top performers are loaded correctly for all stats granularities
You can test the changes on this Pull Request by downloading an installable build, or scanning this QR code:
Codecov Report
Base: 44.10% // Head: 44.10% // Increases project coverage by +0.00% :tada:
Coverage data is based on head (
f7f592a) compared to base (9ee1e74). Patch coverage: 66.66% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## trunk #7411 +/- ##
=========================================
Coverage 44.10% 44.10%
- Complexity 3286 3290 +4
=========================================
Files 582 582
Lines 33126 33146 +20
Branches 4306 4310 +4
=========================================
+ Hits 14609 14620 +11
- Misses 17184 17188 +4
- Partials 1333 1338 +5
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...ommerce/android/ui/mystore/data/StatsRepository.kt | 3.77% <0.00%> (-0.03%) |
:arrow_down: |
| ...woocommerce/android/ui/mystore/MyStoreViewModel.kt | 76.52% <80.00%> (-2.78%) |
:arrow_down: |
| ...erce/android/ui/mystore/domain/GetTopPerformers.kt | 93.10% <91.66%> (-0.23%) |
:arrow_down: |
| ...ommerce/android/push/NotificationMessageHandler.kt | 66.66% <100.00%> (+0.38%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Found 1 violations:
The PR caused the following dependency changes:
expand
-+--- org.wordpress:fluxc:trunk-87eadb05bd327745850ff8accf8ca4dbaa03cece
-| +--- org.wordpress:wellsql:1.7.0
-| | \--- org.wordpress.wellsql:wellsql-annotations:1.7.0
-| +--- org.wordpress.fluxc:fluxc-annotations:trunk-87eadb05bd327745850ff8accf8ca4dbaa03cece
-| +--- org.greenrobot:eventbus:3.3.1 (*)
-| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
-| +--- com.android.volley:volley:1.1.1 -> 1.2.0
-| +--- androidx.paging:paging-runtime:2.1.2
-| | +--- androidx.paging:paging-common:2.1.2
-| | | +--- androidx.annotation:annotation:1.0.0 -> 1.4.0 (*)
-| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
-| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
-| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.5.1 (*)
-| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
-| +--- com.goterl:lazysodium-android:5.0.2
-| +--- net.java.dev.jna:jna:5.5.0
-| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.6.21 (*)
-| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 -> 1.6.21 (*)
-| +--- androidx.appcompat:appcompat:1.0.2 -> 1.4.2 (*)
-| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
-| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3
-| | \--- androidx.annotation:annotation:1.2.0 -> 1.4.0 (*)
-| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
-| | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.6.21 (*)
-| +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
-| +--- org.apache.commons:commons-text:1.1 -> 1.8 (*)
-| +--- androidx.room:room-runtime:2.4.2 (*)
-| +--- androidx.room:room-ktx:2.4.2
-| | +--- androidx.room:room-common:2.4.2 (*)
-| | +--- androidx.room:room-runtime:2.4.2 (*)
-| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 -> 1.6.21 (*)
-| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2 -> 1.6.4 (*)
-| +--- com.google.dagger:dagger:2.42
-| | \--- javax.inject:javax.inject:1
-| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
-| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
++--- org.wordpress:fluxc:trunk-6459816749ce343afcc072dba807f24db1164966
+| +--- org.wordpress:wellsql:1.7.0
+| | \--- org.wordpress.wellsql:wellsql-annotations:1.7.0
+| +--- org.wordpress.fluxc:fluxc-annotations:trunk-6459816749ce343afcc072dba807f24db1164966
+| +--- org.greenrobot:eventbus:3.3.1 (*)
+| +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
+| +--- com.android.volley:volley:1.1.1 -> 1.2.0
+| +--- androidx.paging:paging-runtime:2.1.2
+| | +--- androidx.paging:paging-common:2.1.2
+| | | +--- androidx.annotation:annotation:1.0.0 -> 1.4.0 (*)
+| | | \--- androidx.arch.core:core-common:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.arch.core:core-runtime:2.0.0 -> 2.1.0 (*)
+| | +--- androidx.lifecycle:lifecycle-runtime:2.0.0 -> 2.5.1 (*)
+| | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.5.1 (*)
+| | \--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
+| +--- com.goterl:lazysodium-android:5.0.2
+| +--- net.java.dev.jna:jna:5.5.0
+| +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.6.21 (*)
+| +--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.6.10
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 -> 1.6.21 (*)
+| +--- androidx.appcompat:appcompat:1.0.2 -> 1.4.2 (*)
+| +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
+| +--- androidx.exifinterface:exifinterface:1.0.0 -> 1.3.3
+| | \--- androidx.annotation:annotation:1.2.0 -> 1.4.0 (*)
+| +--- com.squareup.okhttp3:okhttp-urlconnection:4.9.0
+| | +--- com.squareup.okhttp3:okhttp:4.9.0 -> 4.9.3 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10 -> 1.6.21 (*)
+| +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
+| +--- org.apache.commons:commons-text:1.1 -> 1.8 (*)
+| +--- androidx.room:room-runtime:2.4.2 (*)
+| +--- androidx.room:room-ktx:2.4.2
+| | +--- androidx.room:room-common:2.4.2 (*)
+| | +--- androidx.room:room-runtime:2.4.2 (*)
+| | +--- org.jetbrains.kotlin:kotlin-stdlib:1.6.10 -> 1.6.21 (*)
+| | \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2 -> 1.6.4 (*)
+| +--- com.google.dagger:dagger:2.42
+| | \--- javax.inject:javax.inject:1
+| +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
+| \--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
-\--- org.wordpress.fluxc.plugins:woocommerce:trunk-87eadb05bd327745850ff8accf8ca4dbaa03cece
- +--- org.wordpress:wellsql:1.7.0 (*)
- +--- org.wordpress.fluxc:fluxc-annotations:trunk-87eadb05bd327745850ff8accf8ca4dbaa03cece
- +--- androidx.room:room-ktx:2.4.2 (*)
- +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.6.21 (*)
- +--- org.wordpress:fluxc:trunk-87eadb05bd327745850ff8accf8ca4dbaa03cece (*)
- +--- org.apache.commons:commons-lang3:3.7 -> 3.9
- +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
- +--- com.google.dagger:dagger:2.42 (*)
- +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
- +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
- \--- androidx.room:room-runtime:2.4.2 (*)
+\--- org.wordpress.fluxc.plugins:woocommerce:trunk-6459816749ce343afcc072dba807f24db1164966
+ +--- org.wordpress:wellsql:1.7.0 (*)
+ +--- org.wordpress.fluxc:fluxc-annotations:trunk-6459816749ce343afcc072dba807f24db1164966
+ +--- androidx.room:room-ktx:2.4.2 (*)
+ +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10 -> 1.6.21 (*)
+ +--- org.wordpress:fluxc:trunk-6459816749ce343afcc072dba807f24db1164966 (*)
+ +--- org.apache.commons:commons-lang3:3.7 -> 3.9
+ +--- com.google.code.gson:gson:2.8.5 -> 2.9.0
+ +--- com.google.dagger:dagger:2.42 (*)
+ +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9 -> 1.6.4 (*)
+ +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9 -> 1.6.4 (*)
+ \--- androidx.room:room-runtime:2.4.2 (*)
Please review and act accordingly
<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>
<ACCUMULATED-VIOLATIONS>