-
Notifications
You must be signed in to change notification settings - Fork 136
[Bookings] Refactor caching strategy to handle stale data cleanup for all filters #15061
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?
Conversation
Update `cleanAndUpsertBookings` to use the new comprehensive filtering when deleting stale booking records.
The new implementation uses a single `cleanAndUpsertBookings` call when filters are applied, removing the special handling for "Today" or "Upcoming" filters.
| } | ||
| page == 1 && query.isNullOrEmpty() -> { | ||
| // Refreshing with filters applied: selectively remove only the stale entries. | ||
| bookingsDao.cleanAndUpsertBookings(site.localId(), filters, entities) |
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 the main change: cleanAndUpsertBookings() previously received only the date filters, but now it receives the entire filter object.
📲 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 #15061 +/- ##
============================================
- Coverage 38.70% 38.69% -0.02%
+ Complexity 10326 10321 -5
============================================
Files 2162 2162
Lines 122532 122533 +1
Branches 16918 16917 -1
============================================
- Hits 47424 47411 -13
- Misses 70307 70319 +12
- Partials 4801 4803 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This PR addresses a data consistency issue where stale booking data could persist in the local cache when applying filters.
Previously, when fetching filtered bookings, we used a simple
insertOrReplacestrategy. This updated existing bookings but failed to remove bookings that were no longer present in the server response (e.g., deleted bookings or bookings that no longer matched the filter).While we had previously addressed this issue specifically for Today and Upcoming tabs (#15022), this fix extends that same robust cleanup logic to all filter types. It uses a single optimized SQL query to:
Pagination & Data Sync Strategy
To ensure data integrity, we clear the entire cache for the active filter when refreshing the list (page 1).
Why clear pages 2, 3, etc.? Without backend support for deleted items, we can't reliably sync a shifting list client-side.
Test Steps
Images/gif
Before
before-bug.mov
After
after.mov
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.