- 
                Notifications
    
You must be signed in to change notification settings  - Fork 135
 
          [WellSQL Migration] Migrate WCRevenueStatsModel to Room
          #14680
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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)
There was a problem hiding this 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.
        
          
                libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/model/WCRevenueStatsModel.kt
          
            Show resolved
            Hide resolved
        
              
          
                .../fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/persistence/dao/RevenueStatsDao.kt
          
            Show resolved
            Hide resolved
        
              
          
                libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/store/WCStatsStore.kt
          
            Show resolved
            Hide resolved
        
      
          
 Generated by 🚫 Danger  | 
    
          
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
  | 
    
| 
          
 📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build. 
  | 
    
          Codecov Report❌ Patch coverage is  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. 🚀 New features to boost your workflow:
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
        
          
                libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/model/WCRevenueStatsModel.kt
          
            Show resolved
            Hide resolved
        
              
          
                .../fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/persistence/dao/RevenueStatsDao.kt
          
            Show resolved
            Hide resolved
        
              
          
                libs/fluxc-plugin/src/test/java/org/wordpress/android/fluxc/store/WCStatsStoreTest.kt
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …to migrate/wc-revenue-stats-model-to-room
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
PR Comment: https://github.com/woocommerce/woocommerce-android/pull/ 14680#discussion_r2398949700
PR Comment: https://github.com/woocommerce/woocommerce-android/pull/ 14680#discussion_r2407770941
…to migrate/wc-revenue-stats-model-to-room
| 
           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. 🤞  | 
    
…to migrate/wc-revenue-stats-model-to-room
There was a problem hiding this 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
🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆 🥳 🍾 🎆
| 
           Awesome @malinajirka , thank you so much! 🙇 ❤️ 🚀 
 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.
…to migrate/wc-revenue-stats-model-to-room
…to migrate/wc-revenue-stats-model-to-room

Closes: AINFRA-128
Description
This PR migrates
WCRevenueStatsModelfrom WellSQL to Room database.Testing information
My store+PerformanceMy storetab and verify that thePerformancesection is being correctly populated with the expectedRevenuenumber.Performancesection, click on theCalendaricon and selectToday. Verify that the section's title changes to something likeToday Oct 2, 2025and that theRevenuenumber is updated accordingly.This Week,This MonthandThis Yearand verify everything is working as expected.App Inspection, check theRevenueStatsEntitytable, and notice 4 rows being populated, each for every non-custom selection of yours (so far):Today2025-10-022025-10-02(rangeId)Week to Date2025-09-282025-10-04(rangeId)Month to Date2025-10-012025-10-31(rangeId)Year to Date2025-01-012025-12-31(rangeId)Customand edit the section's title picking a specific "single" day likeOct 2 - Oct 2, clickSAVE. Verify that the section's title changes to something likeCustom Oct 2, 2025 - Oct 2, 2025and that theRevenuenumber is updated accordingly.Oct 1 - Oct 2, clickSAVE.Verify that the section's title changes to something like
Custom Oct 1, 2025 - Oct 2, 2025and verify theRevenuenumber is updated accordingly.Custom2025-10-022025-10-02(rangeId)Custom2025-10-012025-10-02(rangeId)Custom2025-09-212025-09-27(rangeId)Custom2025-09-012025-09-30(rangeId)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, seeImages/gifbelow:Images/gif
BEFORE
WCRevenueStatsModelAFTER
RevenueStatsEntityRELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.