-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read and load Surveys, Jobs, and Tasks from proto (#2553)
* Survey, Job, Task proto conversion (Task TODO) * Use `addAll` method for lists * Use `addAll` method for lists * Fix tests * Fix tests p2 * Fix tests p3 * Add tests for SurveyConverter * Add tests for ConditionConverter * Add tests for JobConverter * Add tests for TaskConverter * Add taskID to Condition * Update Copyright year * Update Copyright year * Update Copyright year * Use Kotlin DSLs instead of Builders * Fix linter errors * Small edit to Int converter * Remove backwards compatibility --------- Co-authored-by: Gino Miceli <228050+gino-m@users.noreply.github.com> Co-authored-by: Shobhit Agarwal <ashobhit@google.com>
- Loading branch information
1 parent
34713ac
commit 49ca1e7
Showing
24 changed files
with
643 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...va/com/google/android/ground/persistence/remote/firebase/schema/JobCollectionReference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.ground.persistence.remote.firebase.schema | ||
|
||
import com.google.android.ground.model.job.Job | ||
import com.google.android.ground.persistence.remote.firebase.base.FluentCollectionReference | ||
import com.google.firebase.firestore.CollectionReference | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.callbackFlow | ||
|
||
class JobCollectionReference internal constructor(ref: CollectionReference) : | ||
FluentCollectionReference(ref) { | ||
fun get(): Flow<List<Job>> = callbackFlow { | ||
reference() | ||
.get() | ||
.addOnSuccessListener { trySend(it.documents.map { doc -> JobConverter.toJob(doc) }) } | ||
.addOnFailureListener { trySend(listOf()) } | ||
|
||
awaitClose { | ||
// Cannot cancel or detach listeners here. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.