-
Notifications
You must be signed in to change notification settings - Fork 136
Reduce code duplication in WooPosSyncAction #14856
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
Reduce code duplication in WooPosSyncAction #14856
Conversation
…both-products-and-variations-within-v2-step2
Generated by 🚫 Danger |
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 refactors the paginated data fetching logic for products and variations in the WooCommerce POS local catalog synchronization. The main goal is to eliminate code duplication by introducing a common interface and helper class for handling paginated fetch operations.
Key changes:
- Introduced
WooPosPaginatedFetchResultinterface to standardize paginated fetch results - Created
PaginatedSyncHelperto consolidate duplicated pagination logic - Refactored both product and variation fetch operations to use the new helper class
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WooPosPaginatedFetchResult.kt | New sealed interface defining the contract for paginated fetch results |
| WooPosLocalCatalogFetchProductsResult.kt | Updated to implement WooPosPaginatedFetchResult interface |
| WooPosVariationsFetchResult.kt | Updated to implement WooPosPaginatedFetchResult interface |
| WooPosSyncAction.kt | Major refactoring: removed duplicate pagination logic, introduced PaginatedSyncHelper class, consolidated error handling |
| Project_Default.xml | Formatting changes (indentation standardization) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosSyncAction.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosSyncAction.kt
Show resolved
Hide resolved
📲 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 #14856 +/- ##
============================================
- Coverage 38.26% 38.25% -0.02%
+ Complexity 10080 10073 -7
============================================
Files 2132 2131 -1
Lines 120716 120680 -36
Branches 16554 16546 -8
============================================
- Hits 46190 46164 -26
+ Misses 69835 69825 -10
Partials 4691 4691 ☔ 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.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/store/pos/localcatalog/WooPosPaginatedFetchResult.kt:4
- The generic type parameter
Tshould be documented with a KDoc comment to explain what types of items this result can contain (e.g., products or variations).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosSyncAction.kt
Show resolved
Hide resolved
...in/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosLocalCatalogSyncRepository.kt
Show resolved
Hide resolved
samiuelson
left a comment
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.
LGTM!
Description
This PR refactors WooPosSyncAction - removes code duplication by introducing a helper that fetches data from a paginated endpoint. It also consolidates the returning values for products+variations, so both share the same type.
Test Steps
Green unit tests should be enough - this PR impacts only Local Catalog related classes which are behind a FF (if you'd decide to do manual tests I think it's better to do them on the follow up PR).
Images/gif
N/A
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.