-
Notifications
You must be signed in to change notification settings - Fork 136
[POS][Local Catalog] WooPosVariation #14564
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
[POS][Local Catalog] WooPosVariation #14564
Conversation
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.
|
…s-specific-variation-model-in
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 introduces a POS-specific domain data model WooPosVariation to replace direct usage of the general ProductVariation model within the WooCommerce POS system. The change provides better performance and cleaner separation of concerns for POS functionality.
- Introduces
WooPosVariationdata class containing only POS-relevant fields - Replaces
ProductVariationusage across POS-related classes withWooPosVariation - Moves and adapts the
getNameForPOSextension function to work with the new model
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| WooPosVariation.kt | Defines the new POS-specific variation model with conversion functions |
| WooPosGetVariationById.kt | Updates return type to use WooPosVariation |
| WooPosVariationsViewModel.kt | Removes extension function and updates to use new model |
| WooPosVariationsDataSource.kt | Converts remote variations to WooPosVariation type |
| WooPosVariationsLRUCache.kt | Updates cache type parameters to store WooPosVariation |
| WooPosCartViewModel.kt | Updates variation handling to use new model |
| WooPosSearchByIdentifier*.kt | Updates search functionality to work with new variation model |
| WooPosTotalsRepository.kt | Updates import statements for moved extension function |
| WooPosSearchByIdentifierLocalTest.kt | Updates test mocks to use actual WooPosVariation instances |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/data/WooPosVariation.kt
Outdated
Show resolved
Hide resolved
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/common/data/WooPosVariation.kt
Outdated
Show resolved
Hide resolved
…s-specific-variation-model-in
| val remoteVariationId: Long, | ||
| val remoteProductId: Long, | ||
| val globalUniqueId: String, | ||
| val price: BigDecimal?, |
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.
💡 This is technically enough for now, but we'll likely need to have access to both sale and regular prices quite soon, so I'd consider including them similarly to how we do it in the product model. Having said that, feel free to leave it as is.
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.
I'd leave these props for now and update the model when we need them.
| } else { | ||
| emptyList() | ||
| } | ||
| } catch (e: JsonSyntaxException) { |
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.
❓ I'd consider logging an error into the local log.
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.
I realized this is related to the below comment - since we are doing the parsing within the model, not in a separate class, we don't have access to the logger. I'd personally vote for moving the parsing to a mapper so we can log issues and re-use a single instance of gson.
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.
Yes, parsing logic is now in the WooPosVariationMapper.kt file.
| ) | ||
| } | ||
|
|
||
| private val gson by lazy { Gson() } |
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.
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.
I like the idea, done: abba849
| parentId, | ||
| variationId | ||
| )?.toAppModel() | ||
| )?.toAppModel()?.toWooPosVariation() |
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.
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.
Done in abba849
|
Version |
…s-specific-variation-model-in
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #14564 +/- ##
============================================
- Coverage 38.31% 38.29% -0.03%
- Complexity 9646 9651 +5
============================================
Files 2051 2053 +2
Lines 114860 114976 +116
Branches 15240 15247 +7
============================================
+ Hits 44011 44029 +18
- Misses 66817 66916 +99
+ Partials 4032 4031 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
malinajirka
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 🚢
WOOMOB-1244
Description
This PR introduces POS-specific domain data model for Product Variation to replace direct usage of the
ProductVariation.Steps to reproduce
N/A
Testing information
Ensure that POS works without any visible change
The tests that have been performed
Above
Images/gif
N/A
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.