-
Notifications
You must be signed in to change notification settings - Fork 121
[Local Catalog] Incremental sync: persist incremental sync date in Site storage entity #16108
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
[Local Catalog] Incremental sync: persist incremental sync date in Site storage entity #16108
Conversation
|
|
joshheald
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.
We still need to check how this works a little more with site credential login.
Here's what I think happens:
- Log in with one site's credentials and sync – everything gets persisted to the
-1site ID - Logout – I don't think the site is deleted
- Log in with a different site's credentials – incremental sync will happen, based on the date stored here.
- All the wrong data will still be stored.
If we delete the site on logout, none of this is an issue... but I don't think that will happen.
I want to check what happens with the user defaults site-specific storage too.
| static func createSiteTable(_ db: Database) throws { | ||
| try db.create(table: "site") { siteTable in | ||
| siteTable.primaryKey("id", .integer).notNull() | ||
| siteTable.column("posLastIncrementalSyncDate", .datetime) |
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 think we should avoid mentioning POS in the database layer, until we're sure it's just for POS.
If the store management part of the app starts using this database, we'll want to keep sync working properly. Realistically, I think that means having a single sync controller, not separate ones for POS and the main app. Especially for shared entities such as products/variations.
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.
Makes sense, renamed posLastIncrementalSyncDate to lastCatalogIncrementalSyncDate in f625bab.
| let persistedSite = PersistedSite(from: site) | ||
| try persistedSite.update(db) |
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.
Perhaps PersistedSite needs MutableFetchableRecord?
Seems a little odd to fetch the site and never use it, just replace it.
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.
Seems a little odd to fetch the site and never use it, just replace it.
Did you mean fetching the site from the database? L167 is converting a POSSite to PersistedSite without going through the database.
These two lines are to update the Site in the database from a given POSSite. Feel free to share better ways to do update an existing record.
| private var db: GRDBDatabaseConnection { | ||
| grdbManager.databaseConnection | ||
| } |
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.
👍
Sounds like a similar discussion point to the thread in #16100 (comment). Let's continue the discussion there.
On logout (
|
|
Merging now to make dependent work easier (integrating the incremental sync service to sync coordinator). Feel free to leave suggestions and I'll respond later. |

For WOOMOB-1289
Summary
posLastIncrementalSyncDatecolumn to Site table to track last incremental sync date for POSPOSSitemodel with conversion utilities to bridge Storage and Yosemite layersloadSiteandupdateSitemethods toPOSCatalogPersistenceServicefor site managementPOSCatalogIncrementalSyncServiceto use persisted sync date when determiningmodifiedAfterparameterSteps to reproduce
Just CI is sufficient, as the incremental service isn't integrated with the app yet.
Testing information
I tested that incremental sync worked after a full sync for a big site, making changes to at least one product and variation while full sync is in progress:
After all syncs were complete, I verified that
posLastIncrementalSyncDatewas set to the correct datetime in thesitetable in the sqlite database.RELEASE-NOTES.txtif necessary.