Skip to content

Conversation

@ParaskP7
Copy link
Contributor

@ParaskP7 ParaskP7 commented Oct 2, 2025

Closes: AINFRA-128


Description

This PR migrates WCRevenueStatsModel from WellSQL to Room database.


Testing information

My store + Performance

  1. Navigate on the My store tab and verify that the Performance section is being correctly populated with the expected Revenue number.
  2. On that Performance section, click on the Calendar icon and select Today. Verify that the section's title changes to something like Today Oct 2, 2025 and that the Revenue number is updated accordingly.
  3. Similarly, select This Week, This Month and This Year and verify everything is working as expected.
  4. Open App Inspection, check the RevenueStatsEntity table, and notice 4 rows being populated, each for every non-custom selection of yours (so far):
    • Today: Today2025-10-022025-10-02 (rangeId)
    • This Week: Week to Date2025-09-282025-10-04 (rangeId)
    • This Month: Month to Date2025-10-012025-10-31 (rangeId)
    • This Year: Year to Date2025-01-012025-12-31 (rangeId)
  5. Now, select Custom and edit the section's title picking a specific "single" day like Oct 2 - Oct 2, click SAVE. Verify that the section's title changes to something like Custom Oct 2, 2025 - Oct 2, 2025 and that the Revenue number is updated accordingly.
  6. Then, edit the section's title again, picking any other range, except for a "single" day, like Oct 1 - Oct 2, click SAVE.
    Verify that the section's title changes to something like Custom Oct 1, 2025 - Oct 2, 2025 and verify the Revenue number is updated accordingly.
  7. Try the below custom dates:
    • Oct 2 - Oct 2 (Full Day): Custom2025-10-022025-10-02 (rangeId)
    • Oct 1 - Oct 2 (Partial Week): Custom2025-10-012025-10-02 (rangeId)
    • Sep 21 - Sep 27 (Full Week): Custom2025-09-212025-09-27 (rangeId)
    • Sep 1 - Sep 30 (Full Month): Custom2025-09-012025-09-30 (rangeId)
    • Jan 1 - Oct 2 (Partial Year): Custom2025-01-012025-10-02 (rangeId)

FYI: I've also compared the before (WCRevenueStatsModel) and after (RevenueStatsEntity) migration data on those tables after making the exact same date selections and everything LGTM, see Images/gif below:


Images/gif

image

BEFORE WCRevenueStatsModel

BEFORE(WCRevenueStatsModel)

AFTER RevenueStatsEntity

AFTER(RevenueStatsEntity)
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

FYI: This is done in preparation to the subsequent WellSQL to Room
table migration.
FYI: This change includes but is not limited to the:
- Entity Introduction
- DAO Introduction (With Test)
- WCAndroidDatabase Migration
- Code Adjustments (Store)
- Test Adjustments & Fixes (Store)
@ParaskP7 ParaskP7 added this to the 23.5 milestone Oct 2, 2025
@ParaskP7 ParaskP7 requested a review from Copilot October 2, 2025 13:58
@ParaskP7 ParaskP7 added the type: technical debt Represents or solves tech debt of the project. label Oct 2, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the WCRevenueStatsModel from WellSQL to Room database, part of the broader initiative to modernize the app's data persistence layer.

Key changes include:

  • Converting the WellSQL model to a Room entity with primary key constraints
  • Implementing a new Room DAO for revenue stats operations
  • Updating the store to use the new DAO instead of SQL utilities
  • Converting synchronous database operations to suspend functions

Reviewed Changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
WCRevenueStatsModel.kt Converted from WellSQL table to Room entity with composite primary key
RevenueStatsDao.kt New Room DAO implementing database operations for revenue stats
WCAndroidDatabase.kt Added revenue stats entity and DAO to Room database configuration
WCStatsStore.kt Updated to use Room DAO instead of WellSQL utilities, made functions suspend
WellSqlConfig.kt Added migration to drop the old WellSQL table
WCStatsSqlUtils.kt Removed obsolete WellSQL utility functions
Test files Updated test constructors and mocks to match new data class structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dangermattic
Copy link
Collaborator

dangermattic commented Oct 2, 2025

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 2, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit1a9768c
Direct Downloadwoocommerce-wear-prototype-build-pr14680-1a9768c.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Oct 2, 2025

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

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit1a9768c
Direct Downloadwoocommerce-prototype-build-pr14680-1a9768c.apk

@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 46.26866% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.43%. Comparing base (38975a1) to head (1a9768c).
⚠️ Report is 30 commits behind head on trunk.

Files with missing lines Patch % Lines
.../org/wordpress/android/fluxc/store/WCStatsStore.kt 7.69% 12 Missing ⚠️
...k/rest/wpcom/wc/orderstats/OrderStatsRestClient.kt 0.00% 11 Missing ⚠️
...rdpress/android/fluxc/persistence/WellSqlConfig.kt 0.00% 4 Missing ⚠️
...ndroid/wear/ui/stats/datasource/StatsRepository.kt 0.00% 2 Missing ⚠️
...oocommerce/android/wear/GetWearableMyStoreStats.kt 0.00% 2 Missing ⚠️
...va/com/woocommerce/commons/stats/StatsTimeRange.kt 60.00% 2 Missing ⚠️
...ess/android/fluxc/persistence/WCAndroidDatabase.kt 0.00% 1 Missing ⚠️
...ersistence/converters/StatsGranularityConverter.kt 87.50% 1 Missing ⚠️
...s/android/fluxc/persistence/dao/RevenueStatsDao.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14680      +/-   ##
============================================
+ Coverage     38.41%   38.43%   +0.02%     
- Complexity     9887     9895       +8     
============================================
  Files          2106     2109       +3     
  Lines        117138   117106      -32     
  Branches      15659    15657       -2     
============================================
+ Hits          45001    45013      +12     
+ Misses        67964    67921      -43     
+ Partials       4173     4172       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ParaskP7 ParaskP7 marked this pull request as ready for review October 2, 2025 14:45
@ParaskP7 ParaskP7 requested a review from wzieba October 2, 2025 14:50
Copy link
Contributor

@wzieba wzieba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice job! 👏

Image

I also couldn't make rangeId empty or null. Leaving some comments but nothing blocking.

It seems that 'revenueRangeId' it totally app driven, and not REST API
driven, and as such, can be completely manipulated, effectively becoming
a non-empty value at all times.

With this change, we are making sure that when 'revenueRangeId' comes
from places like 'Widget' or 'Wear', we are adding the necessary missing
information to uniquely identify this revenue range id. We are using
this '<Medium><StartDate><EndDate>' pattern.

FYI: This extra 'Medium' data was added to easily identify the medium.
With or without 'Medium' this would have worked fine anyway.

PS: Where needed, 'Medium' is either 'Widget' or 'Wear'.

------------------------------------------------------------------------

PR Comment: https://github.com/woocommerce/woocommerce-android/pull/
14680#discussion_r2398949681
@ParaskP7 ParaskP7 requested a review from malinajirka October 8, 2025 13:52
@ParaskP7
Copy link
Contributor Author

ParaskP7 commented Oct 9, 2025

A friendly remind on this folks! 🙏 Cc @wzieba @malinajirka

FYI: We are on a meetup next week, then sabbatical, so it would be great to merge this by the end of this week. 🤞

@malinajirka malinajirka self-assigned this Oct 9, 2025
Copy link
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ParaskP7 ! It all looks good to me. I've reviewed the commits as well as tested the app and I haven't found any issues. I've compared the before and after in a split view on UI as well as with App inspector and the data in DB look as expected.

FYI: We are on a meetup next week,

Looking forward to your visit!!!!

then sabbatical

🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆

@ParaskP7
Copy link
Contributor Author

ParaskP7 commented Oct 9, 2025

Awesome @malinajirka , thank you so much! 🙇 ❤️ 🚀

Looking forward to your visit!!!!

I am already excited!!! 😃 x 😃 ^ 😃

🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆

🕺 x 💃 ^ 🕺

FYI: This removes 'StatsTimeRange' from both, the 'WooCommerce' and
'WooCommerce-Wear' modules.
FYI: This removes 'toRevenueRangeId()' from both, the 'WooCommerce' and
'WooCommerce-Wear' modules.
FYI: This removes 'toRevenueRangeId()' from the 'WooCommerce' modules.
@ParaskP7 ParaskP7 merged commit 424f42f into trunk Oct 10, 2025
16 checks passed
@ParaskP7 ParaskP7 deleted the migrate/wc-revenue-stats-model-to-room branch October 10, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: technical debt Represents or solves tech debt of the project.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants