Skip to content

Conversation

@joshheald
Copy link
Contributor

@joshheald joshheald commented Sep 10, 2025

Merge after: #16108

Description

This PR moves the full sync date to the Site entity, to match incremental sync dates.

Steps to reproduce

  1. Launch the app
  2. Observe that you get a full sync (because the site did not have a last sync date)
  3. Launch the app again
  4. Observe that sync doesn't happen the second time

Something like this should be logged:

📋 POSCatalogSyncCoordinator: Last sync for site -1 was 312s ago (max: 86400s), sync not needed

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@joshheald joshheald added this to the 23.3 milestone Sep 10, 2025
@joshheald joshheald added type: task An internally driven task. status: feature-flagged Behind a feature flag. Milestone is not strongly held. feature: POS labels Sep 10, 2025
@joshheald joshheald requested a review from jaclync September 10, 2025 15:34
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 10, 2025

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

App NameWooCommerce iOS Prototype
Build Numberpr16115-759559c
Version23.2
Bundle IDcom.automattic.alpha.woocommerce
Commit759559c
Installation URL7ti2hsmf8ioag
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Base automatically changed from feat/WOOMOB-1289-persist-incremental-sync-date to trunk September 11, 2025 00:55
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 mostly a comment about CIAB files.

Comment on lines 67 to 71
let updatedSite = POSSite(
siteID: siteID,
lastIncrementalSyncDate: currentSite?.lastIncrementalSyncDate,
lastFullSyncDate: Date()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: how about the following in case the site properties grow?

Suggested change
let updatedSite = POSSite(
siteID: siteID,
lastIncrementalSyncDate: currentSite?.lastIncrementalSyncDate,
lastFullSyncDate: Date()
)
let updatedSite = currentSite.toPOSSite().copy(lastFullSyncDate: Date())

do {
try await persistenceService.updateSite(updatedSite)
} catch POSCatalogPersistenceError.siteNotFound {
// Site doesn't exist yet, this could happen if sync coordinator is called before replaceAllCatalogData
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: fullSyncService.startFullSync above in the same function already calls persistenceService.replaceAllCatalogData, this case seems unexpected and maybe deserves an error log?

Comment on lines 1246 to 1247
2DCB54FA2E6AE8E100621F90 /* CIABEligibilityChecker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DCB54F92E6AE8D800621F90 /* CIABEligibilityChecker.swift */; };
2DCB54FC2E6AFE6A00621F90 /* CIABAffectedFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DCB54FB2E6AFE6900621F90 /* CIABAffectedFeature.swift */; };
Copy link
Contributor

Choose a reason for hiding this comment

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

❓Likely from merge conflicts from trunk, are these 2 files meant to be in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for spotting, fixed

Comment on lines 42 to 58
// Check if we have a stored site from updateSite calls
if let storedSite = storedSites[siteID] {
return storedSite
}

// Check if we have a specific result for this site
if let specificSite = siteResults[siteID] {
return specificSite
}

// Fall back to configured result
switch loadSiteResult {
case .success(let site):
return site
case .failure(let error):
throw error
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 this feels like a lot of ways to configure the mock setup, and could be tricky to debug. Feel free to leave it as it is and I can make some changes in my PR that will base on this branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've simplified it a lot by moving the sync date set to the transaction when we insert the catalog.

@joshheald joshheald force-pushed the woomob-1252-sync-coordinator-store-sync-date-on-site branch from a467350 to 0ffe5d7 Compare September 11, 2025 09:20
@joshheald joshheald merged commit a9b92db into trunk Sep 11, 2025
14 checks passed
@joshheald joshheald deleted the woomob-1252-sync-coordinator-store-sync-date-on-site branch September 11, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS status: feature-flagged Behind a feature flag. Milestone is not strongly held. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants