ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Code health] Fixes and cleanup of `LocalMutationSyncWorker`

Open gino-m opened this issue 1 year ago • 1 comments

Code health improvements which came up while fixing #2129:

Recommended:

  • [ ] Warn and ignore mutations not belonging to current signed in user (#2237)
  • [ ] Wrap remoteDataStore.applyMutations in MutationRepository
  • [x] #2236

Nice to have:

  • [ ] Log an error if "create" submissions were enqueued after "edit" submissions
  • [ ] Replace MutationRepository.markAs.. methods with saveMutationsLocally and helper on Mutation
  • [ ] Improve naming of finalizePendingMutationsForMediaUpload() and finalizeDeletions()
  • [ ] Only call enqueueSyncWorker() if media uploads are pending for this LOI
  • [ ] Extract business logic into UserDataUploadUseCase
  • [ ] Move getPendingOrEligibleFailedMutations() into repository (#2237)

Not needed:

  • ~Stop marking all mutations for an LOI as IN_PROGRESS at once. Instead, process each mutation individually, and set IN_PROGRESS before actually processing.~
    • We do this because we process mutations in batch.
  • ~Abort updates to this LOI if any mutations were unsuccessful~
    • Mutations are applied as a batch write, which are atomic.

@scolsen Breaking these out so we can keep moving forward

gino-m avatar Feb 13 '24 22:02 gino-m

https://github.com/google/ground-android/pull/2237 will take care of:

Warn and ignore mutations not belonging to current signed in user Move getPendingOrEligibleFailedMutations() into repository

scolsen avatar Feb 14 '24 16:02 scolsen