Skip to content

Commit

Permalink
Small refactor and TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
gino-m committed Nov 27, 2024
1 parent 356e022 commit ee7ca26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ constructor(

override suspend fun doWork(): Result =
withContext(Dispatchers.IO) {
val mutations =
mutationRepository.getIncompleteMediaUploads().mapNotNull { it.submissionMutation }
val mutations = mutationRepository.getIncompleteMediaUploads()
Timber.d("Uploading photos for ${mutations.size} submission mutations")
val results = mutations.map { uploadAllMedia(it) }
if (results.all { it }) success() else retry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,16 @@ constructor(
* Return the set of photo/media upload queue entries not yet marked as completed, sorted in
* chronological order (FIFO).
*/
suspend fun getIncompleteMediaUploads(): List<UploadQueueEntry> =
getUploadQueueFlow().first().filter {
setOf(MEDIA_UPLOAD_PENDING, MEDIA_UPLOAD_IN_PROGRESS, MEDIA_UPLOAD_AWAITING_RETRY)
.contains(it.uploadStatus)
}
suspend fun getIncompleteMediaUploads(): List<SubmissionMutation> =
getUploadQueueFlow()
.first()
.filter {
setOf(MEDIA_UPLOAD_PENDING, MEDIA_UPLOAD_IN_PROGRESS, MEDIA_UPLOAD_AWAITING_RETRY)
.contains(it.uploadStatus)
}
// TODO(https://github.com/google/ground-android/issues/2120):
// Return [MediaMutations] instead once introduced.
.mapNotNull { it.submissionMutation }

/**
* Returns a [Flow] which emits the upload queue once and on each change, sorted in chronological
Expand Down

0 comments on commit ee7ca26

Please sign in to comment.