Skip to content

Update firebase mappings to improve performance on large surveys - #3868

Merged
andreia-ferreira merged 10 commits into
masterfrom
andreia/3866/improve-large-survey-load
Aug 20, 2026
Merged

Update firebase mappings to improve performance on large surveys#3868
andreia-ferreira merged 10 commits into
masterfrom
andreia/3866/improve-large-survey-load

Conversation

@andreia-ferreira

Copy link
Copy Markdown
Collaborator

Towards #3866

Loading large surveys could be very slow. One of the factors was using expensive java reflection lookups on every field of every LOI as well as storing unused properties that could be very large (especially if whisp integration is enabled on the survey). This PR optimizes that:

  • Added LoiGeometryConverter to read geometry directly from the Firestore document instead of through the reflection-based proto mapper
  • Filter LOI properties and only store the ones that the app uses
  • Cache resolved builder methods (declaredFunctions was re-running for every field of every document)
  • Set FIRESTORE_LOGGING_ENABLED as false in release builds, as writing down logs for large surveys can be quite heavy

After testing with some user surveys from Vietnam, these changes were shown to cut in half the time needed to download

@shobhitagarwal1612 PTAL?

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.89474% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.55%. Comparing base (9de6285) to head (22c5386).

Files with missing lines Patch % Lines
...ndroid/data/remote/firebase/schema/LoiConverter.kt 70.58% 0 Missing and 5 partials ⚠️
...remote/firebase/protobuf/FirestoreToProtobufExt.kt 57.14% 2 Missing and 1 partial ⚠️
...mote/firebase/protobuf/MessageLiteReflectionExt.kt 85.00% 0 Missing and 3 partials ⚠️
...ava/org/groundplatform/android/common/Constants.kt 0.00% 0 Missing and 1 partial ⚠️
...ata/remote/firebase/schema/LoiGeometryConverter.kt 96.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3868      +/-   ##
============================================
+ Coverage     68.47%   68.55%   +0.07%     
- Complexity     1898     1911      +13     
============================================
  Files           411      412       +1     
  Lines         10915    10968      +53     
  Branches       1425     1432       +7     
============================================
+ Hits           7474     7519      +45     
- Misses         2699     2701       +2     
- Partials        742      748       +6     
Files with missing lines Coverage Δ
...ava/org/groundplatform/android/common/Constants.kt 66.66% <0.00%> (-33.34%) ⬇️
...ata/remote/firebase/schema/LoiGeometryConverter.kt 96.77% <96.77%> (ø)
...remote/firebase/protobuf/FirestoreToProtobufExt.kt 70.31% <57.14%> (-1.36%) ⬇️
...mote/firebase/protobuf/MessageLiteReflectionExt.kt 68.42% <85.00%> (+5.73%) ⬆️
...ndroid/data/remote/firebase/schema/LoiConverter.kt 80.48% <70.58%> (-10.43%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andreia-ferreira
andreia-ferreira merged commit 85b7a02 into master Aug 20, 2026
19 checks passed
@andreia-ferreira
andreia-ferreira deleted the andreia/3866/improve-large-survey-load branch August 20, 2026 15:20
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.

2 participants