woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
262 stars 133 forks source link

[Dynamic Dashboard] Fix issue of not updating the orders count in some scenarios #11530

Closed hichamboushaba closed 2 weeks ago

hichamboushaba commented 2 weeks ago

Description

In some cases, and given the fact that order status options are fetched only on app launch and when switching sites, it could happen that the app shows the performance card for stores with no orders or vice versa.

This PR fixes this by making two changes:

  1. It updates the logic of ObserveProcessingOrdersCount to always use the order status API for infering the number of processing orders, instead of using the /wc-analytics/reports/totals endpoint, this update will allow us to refresh the cache whenever any changes happen.
  2. It updates the logic of ObserveSiteOrdersState to observe the changes of order status options instead of retrieving a single snapshot.

With these two changes, the dashboard will always observe the updated state.

Testing instructions

  1. Use a store with a single order.
  2. Open the app.
  3. Notice the performance card is shown.
  4. Switch to the order list screen.
  5. Delete the order.
  6. Go back to the dashboard screen.
  7. Notice the performance card was disabled (there could be a small delay for this, and it's because of the delay of the undo action that we use before trashing the order).
  8. Repeat the test with "adding a new order"
  9. Notice the performance card was enabled.

Images/gif

https://github.com/woocommerce/woocommerce-android/assets/1657201/75de6a5a-537d-4fd6-878c-22bac62c5e47

dangermattic commented 2 weeks ago
1 Message
:book:

This PR contains changes to Tracks-related logic. Please ensure (author and reviewer) the following are completed:

  • The tracks events must be validated in the Tracks system.
  • Verify the internal Tracks spreadsheet has also been updated.
  • Please consider registering any new events.
  • The PR must be assigned the category: tracks label.

Generated by :no_entry_sign: Danger

wpmobilebot commented 2 weeks ago

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
FlavorJalapeno
Build TypeDebug
Commit53d9227754b73a9cd047d835474d1dda477e627d
Direct Downloadwoocommerce-prototype-build-pr11530-53d9227.apk
codecov-commenter commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 41.37931% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 40.46%. Comparing base (e4cc452) to head (4be19ab). Report is 54 commits behind head on trunk.

:exclamation: Current head 4be19ab differs from pull request most recent head 73e7b31

Please upload reports for the commit 73e7b31 to get more accurate results.

Files Patch % Lines
...ce/android/ui/main/ObserveProcessingOrdersCount.kt 57.14% 7 Missing and 2 partials :warning:
...ndroid/ui/dashboard/data/ObserveSiteOrdersState.kt 0.00% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## trunk #11530 +/- ## ============================================ - Coverage 40.47% 40.46% -0.01% + Complexity 5181 5180 -1 ============================================ Files 1075 1075 Lines 62873 62872 -1 Branches 8612 8606 -6 ============================================ - Hits 25447 25444 -3 - Misses 35138 35141 +3 + Partials 2288 2287 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

hichamboushaba commented 2 weeks ago

@0nko thanks for the test, can you invite me to your store to check this? This doesn't happen on my store, trash is not returned as a status option for me, which means the trashed orders are not counted.