Skip to content

Implement incremental LOI sync - #3918

Merged
andreia-ferreira merged 7 commits into
masterfrom
andreia/3867/avoid-sync-all-lois
Sep 10, 2026
Merged

Implement incremental LOI sync#3918
andreia-ferreira merged 7 commits into
masterfrom
andreia/3867/avoid-sync-all-lois

Conversation

@andreia-ferreira

@andreia-ferreira andreia-ferreira commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3867

FCMs now carry deleted and loiId, which we apply straight as a local delete rather than discovering it through a full read. That's only a shortcut, so before each incremental sync we compare the server's LOI count against the local one and fall back to a full read if needed.

A full read still happens in the following cases:

  • the survey has never been synced
  • the server holds fewer LOIs than we expect, which means a delete happened and a FCM was lost or collapsed
  • the survey's data visibility changed, since that changes which LOIs we should hold
  • the last full read was over 7 days ago, as a catch-all

The count operation used to detect delete cases bills 1 read per 1K LOIs so it is lightweight, but soft deletion on the server side should be a future improvement for this implementation.

@shobhitagarwal1612 PTAL?

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.34146% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.99%. Comparing base (35cad76) to head (eb9381e).

Files with missing lines Patch % Lines
...android/repository/LocationOfInterestRepository.kt 90.62% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3918      +/-   ##
============================================
+ Coverage     69.75%   69.99%   +0.24%     
- Complexity     2009     2034      +25     
============================================
  Files           422      424       +2     
  Lines         11594    11648      +54     
  Branches       1511     1522      +11     
============================================
+ Hits           8087     8153      +66     
+ Misses         2737     2722      -15     
- Partials        770      773       +3     
Files with missing lines Coverage Δ
...a/local/room/stores/RoomLocationOfInterestStore.kt 93.10% <100.00%> (+0.94%) ⬆️
...data/local/room/stores/RoomSurveySyncStateStore.kt 100.00% <100.00%> (ø)
...d/data/remote/firebase/FirebaseMessagingService.kt 100.00% <100.00%> (ø)
...a/remote/firebase/schema/LoiCollectionReference.kt 100.00% <100.00%> (ø)
...undplatform/android/repository/SurveyRepository.kt 84.00% <100.00%> (+4.00%) ⬆️
.../org/groundplatform/domain/model/SurveySyncMode.kt 100.00% <100.00%> (ø)
...atform/domain/usecases/survey/SyncSurveyUseCase.kt 100.00% <100.00%> (ø)
...android/repository/LocationOfInterestRepository.kt 68.51% <90.62%> (+3.25%) ⬆️

... and 3 files with indirect coverage changes

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

@shobhitagarwal1612 shobhitagarwal1612 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we break this PR into 2 parts? First introduces the necessary room tables, daos, etc. Second one with the rest of the changes?

@andreia-ferreira
andreia-ferreira force-pushed the andreia/3867/avoid-sync-all-lois branch from 4c97b1b to b77928a Compare September 9, 2026 16:52
@andreia-ferreira
andreia-ferreira marked this pull request as ready for review September 9, 2026 17:03
@andreia-ferreira

Copy link
Copy Markdown
Collaborator Author

done! This PR is ready for review now that most of the Room changes have been merged

@andreia-ferreira
andreia-ferreira merged commit bf1fdfb into master Sep 10, 2026
21 of 23 checks passed
@andreia-ferreira
andreia-ferreira deleted the andreia/3867/avoid-sync-all-lois branch September 10, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

App doing too many unecessary reads from Firebase

2 participants