[MS-1052] CoDownSync Phase 2 - Handle diffs with CommCare#1294
Conversation
536942d to
719cf52
Compare
719cf52 to
8dc47de
Compare
e529332 to
30057b8
Compare
67ff4c4 to
28a4d0a
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements CommCare sync phase 2 functionality to handle differential syncing by tracking synced cases and their modification timestamps. The implementation introduces a caching mechanism to sync only new or modified cases while cleaning up deleted ones.
Key changes:
- Added CommCare sync cache to track case IDs, their corresponding Simprints IDs, and last sync timestamps
- Implemented differential sync logic that only processes cases modified after the last sync
- Added support for generating deletion events for cases no longer present in CommCare
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| CommCareSyncCache.kt | New cache implementation for tracking synced CommCare cases |
| CommCareSyncDao.kt | Database access object for CommCare sync cache operations |
| CommCareSyncDatabase.kt | Room database configuration for the sync cache |
| SyncedCaseEntity.kt | Entity representing cached case data with timestamps |
| CommCareEventDataSource.kt | Enhanced to implement differential sync logic and cache management |
| BaseEventDownSyncTask.kt | Modified callback mechanism from actions to events |
| CommCareEventSyncTask.kt | Simplified to delegate cache operations to data source |
| SimprintsEventDownSyncTask.kt | Removed unused cleanup method |
| EventSyncModule.kt | Added dependency injection for CommCare cache components |
| EventSyncManagerImpl.kt | Added cache clearing to sync reset operations |
| Test files | Comprehensive test coverage for new functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
28a4d0a to
405881e
Compare
405881e to
e672999
Compare
| val casesToParse = mutableListOf<SyncedCaseEntity>() | ||
| val caseIdsPresentInCommCare = mutableListOf<String>() | ||
| // Fetch all previously synced cases with their details (including lastSyncedTimestamp) | ||
| val previouslySyncedCasesMap = commCareSyncCache.getAllSyncedCases() |
There was a problem hiding this comment.
It seems that you only need the caseId and lastModified values, so it could be more memory efficient to use `Map<String, Long> instead. You can filter by key later when removing cases.
There was a problem hiding this comment.
Yes but then you need to pass the full SyncedCaseEntity to generateEnrolmentRecordDeletionEvent() because it uses its simprintsId. So, in the end we do need the full 'cases'.
e672999 to
182e3ce
Compare
|



JIRA ticket
Will be released in: 2025.3.0
Notable changes
onEventsProcessed()is added.Testing guidance
Additional work checklist