-
Notifications
You must be signed in to change notification settings - Fork 137
Issue/woomob 1867 woo pos implement catalog feed polling mechanism #15093
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: trunk
Are you sure you want to change the base?
Issue/woomob 1867 woo pos implement catalog feed polling mechanism #15093
Conversation
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 new polling mechanism for catalog feed generation in WooCommerce POS. The implementation includes a new action that polls a server endpoint until catalog generation completes or reaches a maximum number of attempts. The code is behind a feature flag and not yet integrated into the main flow.
- Added
WooPosFileBasedSyncActionwith exponential backoff polling logic for catalog generation - Converted catalog state from String to enum type (
WooPosGenerateCatalogState) for better type safety - Added new failure type
CatalogGenerationTimeoutto handle polling timeout scenarios
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| WooPosFileBasedSyncAction.kt | New action class implementing catalog generation with polling and exponential backoff |
| WooPosFileBasedSyncActionTest.kt | Comprehensive test suite for the new polling action covering success, failure, and timeout scenarios |
| WooPosGenerateCatalogResult.kt | Changed state field from nullable String to enum type and added WooPosGenerateCatalogState enum |
| WooPosLocalCatalogStore.kt | Updated to convert response state string to enum using the new from() method |
| FeatureFlag.kt | Added WOO_POS_LOCAL_CATALOG_FILE_APPROACH feature flag (currently disabled) |
| WooPosSyncResult.kt | Added CatalogGenerationTimeout failure type for timeout scenarios |
| WooPosLocalCatalogSyncWorker.kt | Added handling for the new CatalogGenerationTimeout failure case |
| WooPosLocalCatalogSyncRepository.kt | Mapped CatalogGenerationTimeout to analytics error type |
| WooPosAnalyticsEventConstant.kt | Added CATALOG_GENERATION_TIMEOUT analytics constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
Show resolved
Hide resolved
.../test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
Show resolved
Hide resolved
.../test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
Show resolved
Hide resolved
.../test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
Show resolved
Hide resolved
.../src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncAction.kt
Show resolved
Hide resolved
.../src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncAction.kt
Outdated
Show resolved
Hide resolved
.../test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
Outdated
Show resolved
Hide resolved
.../src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncAction.kt
Outdated
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 #15093 +/- ##
============================================
+ Coverage 38.53% 38.56% +0.02%
- Complexity 10397 10412 +15
============================================
Files 2173 2174 +1
Lines 123725 123795 +70
Branches 17050 17063 +13
============================================
+ Hits 47676 47739 +63
- Misses 71238 71240 +2
- Partials 4811 4816 +5 ☔ 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 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../test/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosFileBasedSyncActionTest.kt
Show resolved
Hide resolved
…-feed-polling-mechanism
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!
| "scheduled" -> SCHEDULED | ||
| "in_progress" -> IN_PROGRESS | ||
| "completed" -> COMPLETED | ||
| else -> UNKNOWN |
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.
Out of curiosity: does the backend also return "error" for the catalog generation successful response, or rather an error response type?
| private const val MAX_POLL_ATTEMPTS = 20 | ||
| private const val MAX_CONSECUTIVE_FAILED_ATTEMPTS = 3 | ||
|
|
||
| // Backoff settings |
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.
| // Backoff settings |
| var attemptCount = 0 | ||
| var failedConsecutiveAttempts = 0 | ||
|
|
||
| while (attemptCount < MAX_POLL_ATTEMPTS) { |
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.
💡 n.p.: repeat(MAX_POLL_ATTEMPTS) { attemptIndex -> ... } would be more idiomatic, a bit easier to understand, and maintain the code. However, keep in mind that this suggestion may just be my personal taste, and feel free to ignore it.
#WOOMOB-1867
Description
This PR introduces a new action and a feature flag. The code isn't used yet - this will be done in follow up PRs.
The action poll the server (/catalog) endpoint, until
or
or
Test Steps
Green CI should be enough since the code isn't used yet.
Images/gif
N/A
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.