Repository navigation
Reduce Firestore reads from survey sync and survey list - #3984
rfontanarosa wants to merge 11 commits into
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors SurveysCollectionReference to use one-shot reads via flow and get().await() instead of realtime listeners, reducing Firestore read costs. It also increases the sync delay in SurveySyncService to 30 minutes to bound reads, and updates the corresponding unit tests. The review feedback recommends ensuring main-safety for these cold flows by applying .flowOn(Dispatchers.IO) to offload the CPU-intensive document parsing from the main thread.
There was a problem hiding this comment.
Code Review
This pull request refactors SurveysCollectionReference to perform one-shot reads instead of using real-time listeners for getReadable and getPublicReadable, and increases the sync delay in SurveySyncService to 30 minutes to optimize Firestore usage. The review feedback suggests offloading these database queries and mapping operations to Dispatchers.IO to avoid blocking the main thread, and adding unit tests for getPublicReadable to comply with the repository style guide.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3984 +/- ##
============================================
+ Coverage 70.03% 70.08% +0.04%
- Complexity 2106 2113 +7
============================================
Files 441 441
Lines 11869 11892 +23
Branches 1545 1555 +10
============================================
+ Hits 8313 8334 +21
+ Misses 2780 2776 -4
- Partials 776 782 +6
🚀 New features to boost your workflow:
|
…rom-survey-sync-and-survey-list
…rom-survey-sync-and-survey-list
…rom-survey-sync-and-survey-list
…rom-survey-sync-and-survey-list
…rom-survey-sync-and-survey-list
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors survey retrieval in SurveysCollectionReference from real-time listeners (snapshots()) to one-shot reads (get().await()) to reduce Firestore billing costs, and increases the sync delay in SurveySyncService to 30 minutes. Corresponding unit tests have been updated and expanded. Feedback highlights that switching to one-shot reads might introduce UI latency on slow networks and recommends caching the resulting cold flow to avoid redundant requests. Additionally, the 30-minute sync delay is noted as potentially too long, and introducing randomized jitter is suggested to prevent a 'thundering herd' problem when multiple devices sync simultaneously.
…rom-survey-sync-and-survey-list
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request optimizes survey synchronization by splitting the process into two separate workers: a quick one for the survey definition and a delayed, jittered one for the Locations of Interest (LOIs). It also replaces realtime Firestore listeners with one-shot reads using coroutines and flows to reduce read costs. The reviewer suggested removing the blocking .result.get() call on the Operation returned by enqueueUniqueWork to prevent potential UI stutters or ANRs on the main thread.
…rom-survey-sync-and-survey-list
closes #3983