-
Notifications
You must be signed in to change notification settings - Fork 133
[Woo POS][Local Catalog] Full sync missing/overdue handling #14678
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?
[Woo POS][Local Catalog] Full sync missing/overdue handling #14678
Conversation
📲 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 #14678 +/- ##
============================================
+ Coverage 38.38% 38.42% +0.03%
- Complexity 9836 9854 +18
============================================
Files 2094 2096 +2
Lines 116801 116988 +187
Branches 15633 15667 +34
============================================
+ Hits 44837 44950 +113
- Misses 67801 67868 +67
- Partials 4163 4170 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…n-pos-splash' into woomob-1412-woo-poslocal-catalog-full-sync-overdue-handling
Generated by 🚫 Danger |
…overdue-handling # Conflicts: # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/WooPosItemsScreen.kt
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 enhances the reliability of POS local catalog full sync by implementing overdue handling. Previously, if a device was turned off during the scheduled nightly full sync, the sync could fail indefinitely. This change adds tracking and automatic recovery for overdue syncs.
Key changes:
- Added timestamp tracking for full sync completion
- Implemented overdue sync detection (24-hour threshold)
- Added automatic background sync triggering when sync is overdue
- Moved incremental sync from splash screen to POS home initialization
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
WooPosLocalCatalogStore.kt | Added product count method for catalog validation |
WooPosProductsDao.kt | Added SQL query to count products in local database |
WooPosSyncTimestampRepository.kt | Added methods to store and retrieve full sync completion timestamps |
WooPosSyncTimestampManager.kt | Added wrapper methods for full sync timestamp management |
WooPosPerformInitialCatalogFullSync.kt | New use case handling initial sync with overdue detection logic |
WooPosFullSyncCheckUseCase.kt | New use case for checking and triggering overdue syncs on app start |
WooPosLocalCatalogSyncWorker.kt | Updated to store completion timestamp after successful sync |
WooPosSplashViewModel.kt | Removed incremental sync from splash screen initialization |
WooPosHomeViewModel.kt | Added catalog sync state management and incremental sync triggering |
WooPosHomeScreen.kt | Added sync overlay UI components for progress and error states |
AppInitializer.kt | Added overdue sync check on app startup |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosPerformInitialCatalogFullSync.kt
Show resolved
Hide resolved
...kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosPerformInitialCatalogFullSync.kt
Show resolved
Hide resolved
suspend fun getFullSyncLastCompletedTimestamp(): Long? { | ||
val key = buildSiteSpecificKey(FULL_SYNC_TIMESTAMP_KEY) | ||
return if (key != null) { | ||
dataStore.data.first()[key]?.toLong() |
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.
The toLong()
call can throw a NumberFormatException if the stored string is not a valid long. Consider using toLongOrNull()
and handling the null case.
Copilot uses AI. Check for mistakes.
emit(WooPosFullSyncStatus.InProgress) | ||
|
||
var workerStillRunning = true | ||
while (workerStillRunning) { |
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'll investigate if it's possible to replace while with getWorkInfoById.
WOOMOB-1412
Description
The goal of PR is to improve the reliability of the full sync of POS local catalog.
The full sync is scheduled to be performed every 24h, at night. However, in case the device was turned off at night, the sync may not succeed. To handle such case, this PR adds:
trunk
.Steps to reproduce
Testing information
Verify that WooPosLocalCatalogSyncWorker is being scheduled and completes when the app is opened, in case previous one was not done within last 24h.
The tests that have been performed
Above.
Images/gif
N/A
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.