-
Notifications
You must be signed in to change notification settings - Fork 131
WCProductCategoryModel
to Room
#13996
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
base: migrate_product_variation_to_room_tests
Are you sure you want to change the base?
WCProductCategoryModel
to Room
#13996
Conversation
…s DAO and use select queries from it in the app
`rowsAffected` fiels was not used in any meaningful way and Room doesn't support this, hence removal.
…luxc-plugin` module
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.
|
Use constructor instead of copy when it's possible. Remove unused methods
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## migrate_product_variation_to_room_tests #13996 +/- ##
=============================================================================
+ Coverage 38.31% 38.35% +0.04%
- Complexity 9515 9516 +1
=============================================================================
Files 2119 2120 +1
Lines 116382 116265 -117
Branches 14934 14931 -3
=============================================================================
+ Hits 44593 44595 +2
+ Misses 67708 67590 -118
+ Partials 4081 4080 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There's something off with |
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 WCProductCategoryModel from legacy SQL-based operations to Room, replacing functions in the store, DAO, network client, and test utilities. Key changes include:
- Refactoring database operations to use the ProductCategoriesDao with Room (upsert, delete, observe).
- Updating API conversion methods to use immutable data classes via copy().
- Modifying tests and UI components to accommodate the suspend functions and Room-based model.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
ProductTestUtils.kt | Removed legacy helper generators and updated getProductCategories() to use constructor-based model creation. |
WCProductLeaderboardsMapperTest.kt & WCLeaderboardsStoreTest.kt | Added productCategoriesDao usage to tests. |
WCProductStore.kt | Migrated category-related operations from ProductSqlUtils to Room DAO calls. |
ProductCategoriesDao.kt | New DAO definition for WCProductCategoryModel with Room annotations. |
WCAndroidDatabase.kt | Added WCProductCategoryModel to the Room database with updated version and migration. |
ProductSqlUtils.kt | Removed legacy SQL functions for product categories. |
ProductRestClient.kt & ProductCategoryApiResponse.kt | Updated category model conversion to use copy() for immutability. |
WCProductCategoryModel.kt | Converted from mutable model with WellSQL annotations to an immutable data class with Room Entity annotation. |
WCDatabaseModule.kt | Provided injection for the new ProductCategoriesDao. |
GetCategoriesByIdsTest.kt, ProductCategoriesRepository.kt, AddProductCategoryViewModel.kt, AddProductCategoryFragment.kt | Updated tests and repository functions to work with the Room migration and suspend functions. |
Comments suppressed due to low confidence (2)
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/categories/AddProductCategoryFragment.kt:115
- Consider using viewLifecycleOwner.lifecycleScope.launch { ... } instead of runBlocking to asynchronously fetch and set the parent category name, avoiding potential UI thread blocking.
runBlocking { viewModel.getSelectedParentCategoryName()?.let { setText(it) } }
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/categories/AddProductCategoryFragment.kt:167
- Replace runBlocking with an asynchronous call using lifecycleScope to prevent UI thread blocking during click handling.
val parentCategoryName = runBlocking { viewModel.getSelectedParentCategoryName() }
WCProductCategoryModel
to RoomWCProductCategoryModel
to Room
Closes: AINFRA-125
Description
This PR migrates
WCProductCategoryModel
to Room.Testing information
Smoke test any feature that uses
WCProductCategoryModel
.Images/gif
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: