Skip to content

[WOOMOB-2442] Fix incremental sync missing product updates for sites with negative UTC offsets#15494

Merged
malinajirka merged 4 commits intorelease/24.3from
woomob-2442-incremental-sync-misses-product-updates-for-sites-with
Mar 9, 2026
Merged

[WOOMOB-2442] Fix incremental sync missing product updates for sites with negative UTC offsets#15494
malinajirka merged 4 commits intorelease/24.3from
woomob-2442-incremental-sync-misses-product-updates-for-sites-with

Conversation

@malinajirka
Copy link
Copy Markdown
Contributor

Description

Fixes WOOMOB-2442

During incremental sync, the POS sends a modified_after parameter to filter products changed since the last sync. The stored timestamp comes from the server's response header and is always in UTC. However, the WooCommerce REST API compares modified_after against date_modified, which is stored in the site's local timezone. For sites with negative UTC offsets, the UTC value is always ahead of the local date_modified, causing recently modified products to be excluded from the sync response.

This fix converts the UTC timestamp to site-local time (using SiteModel.timezone) at the REST client level before sending the modified_after parameter, so all callers (products, variations, catalog size check) automatically get the correction.

Test Steps

  1. Configure a WooCommerce site with a negative UTC offset (e.g., UTC-6, America/Chicago)
  2. Open the POS and wait for the initial full sync to complete
  3. On the site's admin, modify a product (e.g., change the price)
  4. Return to the POS and trigger an incremental sync (pull to refresh or wait for periodic sync)
  5. Verify the modified product is updated in the POS catalog
  6. Repeat with a site in a positive UTC offset (e.g., UTC+5:30) and a UTC+0 site to confirm no regressions

Images/gif

N/A

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Adds logic to convert `modified_after` timestamps from UTC to site-local time when querying products and variations. Includes utility function for adjusting time based on site timezone offset to ensure accurate API filtering.
… WooPosProductRestClient

Introduces comprehensive unit tests to verify timestamp adjustment logic based on site timezone offsets, ensuring accurate handling across various edge cases.
@malinajirka malinajirka added feature: point of sale POS project type: bug A confirmed bug. labels Mar 6, 2026
@malinajirka malinajirka requested a review from Copilot March 6, 2026 09:16
@malinajirka malinajirka added this to the 24.3 milestone Mar 6, 2026
if (offsetHours == 0.0) return utcDateString

val offsetSeconds = (offsetHours * SECONDS_PER_HOUR).toInt()
val zoneOffset = ZoneOffset.ofTotalSeconds(offsetSeconds)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📓 We need to convert to seconds and offset seconds, since ofHours doesn't support fractional offsets like 5.5 (UTC+5:30, India).

@malinajirka malinajirka marked this pull request as ready for review March 6, 2026 09:20
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 fixes WOOMOB-2442 by adjusting the modified_after timestamp used for POS incremental catalog syncs so it matches WooCommerce REST API’s comparison behavior against date_modified in the site’s local (GMT-offset) time, preventing missed updates on sites with negative UTC offsets.

Changes:

  • Convert modifiedAfter (UTC) to site-local time (via site GMT offset) before sending modified_after in product and variation fetches.
  • Add unit tests covering negative/positive/zero/null/non-numeric offsets and date rollovers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClient.kt Adjusts modified_after to site-local time before calling the REST API.
libs/fluxc-plugin/src/test/java/org/wordpress/android/fluxc/network/rest/wpcom/wc/product/pos/WooPosProductRestClientTest.kt Adds tests validating UTC→site-local timestamp adjustment behavior and rollovers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…n in WooPosProductRestClient

Introduces a try-catch block to handle `DateTimeException` during UTC to site-local time conversion. Logs the error and falls back to the UTC string.
@malinajirka malinajirka requested a review from samiuelson March 6, 2026 09:27
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 6, 2026

App Icon📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Build Number731
Version24.2.1
Application IDcom.woocommerce.android.prealpha
Commitc3c3166
Installation URL3bssql44hri2o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.44%. Comparing base (5930121) to head (c3c3166).
⚠️ Report is 71 commits behind head on release/24.3.

Files with missing lines Patch % Lines
...st/wpcom/wc/product/pos/WooPosProductRestClient.kt 73.33% 4 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##             release/24.3   #15494   +/-   ##
===============================================
  Coverage           39.43%   39.44%           
- Complexity          11148    11156    +8     
===============================================
  Files                2248     2248           
  Lines              129078   129091   +13     
  Branches            18058    18061    +3     
===============================================
+ Hits                50907    50921   +14     
  Misses              72974    72974           
+ Partials             5197     5196    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpmobilebot wpmobilebot modified the milestones: 24.3, 24.4 Mar 6, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

Version 24.3 has now entered code-freeze, so the milestone of this PR has been updated to 24.4.

Copy link
Copy Markdown
Contributor

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

"regular_price,sale_price,date_modified,stock_quantity,stock_status,manage_stock," +
"backordered,attributes,image,downloadable,name,type"

private const val SECONDS_PER_HOUR = 3600
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could be using 1.hours.inWholeSeconds from std lib instead. It's a matter of taste though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in c3c3166

Replaces manual calculation of seconds per hour with Kotlin's `Duration` API for improved readability and consistency.
@malinajirka malinajirka changed the base branch from trunk to release/24.3 March 9, 2026 10:38
@malinajirka malinajirka merged commit 1507d44 into release/24.3 Mar 9, 2026
17 checks passed
@malinajirka malinajirka deleted the woomob-2442-incremental-sync-misses-product-updates-for-sites-with branch March 9, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: point of sale POS project type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants