Proposal / Discussion
We are showing thumbs-up instead of a session survey.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /confsched/2020 {
...
match /sessions/{sessionId} {
match /{allSubcollections=**} {
allow create
}
// Allow to increment only the 'shards' field and only by 1.
match /thumbsup_counters/{counterId} {
allow get;
allow write: if request.resource.data.keys() == ["shards"]
&& (resource == null || request.resource.data.shards ==
resource.data.shards + 1);
}
}
}
}
}
https://www.figma.com/file/4r9becvhDy3GfXaXex8E8d/App?node-id=21%3A289
| now | design |
|---|---|
|
|
|
## Links
Can I challenge this issue ? π
Thank you! Please ask if you have anything π₯
@takahirom
I would like to avoid to post to database for release.
The firestore which specified android-base/arc/debug/google-services.json is test database for develop, isn't it?
@mkeeda Yes. That google-services.json is for develop π
confsched/2020/sessions/${sessionId}/thumbsup_counters/${userId}/shards/${shardsId}π
@mkeeda
confsched/2020/sessions/${sessionId}/thumbsup_counters/${counterId}/shards/1
How about sharing data with other users in this way?
@takahirom
I'm thinking to share data with other users, but I don't understand what to mean /thumbsup_counters/${counterId}/.
Why is multiple counters in thumbs-up collection?
Are the single thumbs-up counter of each session some problems, like confsched/2020/sessions/${sessionId}/thumbsup_counter/shards/${shardId}?
Are the single thumbs-up counter of each session some problems, like
confsched/2020/sessions/${sessionId}/thumbsup_counter/shards/${shardId}?
Sorry, I did not notice this document of firestore.
Notice the alternating pattern of collections and documents. Your collections and documents must always follow this pattern. You cannot reference a collection in a collection or a document in a document.
https://firebase.google.com/docs/firestore/data-model?hl=en
.../thumbsup_counter/shards/${shardId} is collection in collection; .../collection/collection/document, so it's wrong setting.
sessions/${sessionId}/thumbsup_counter/${shardId}
Probably we can remove like this?π
I forgot why counterId is existsπ€π€
@takahirom
Thank youπ
I summarized the plans for sharing thumbs-up counts with all users.
sessions/${sessionId}/thumbsup_counters/${userId}/shards/${shardsId}
number of user * number of shard.sessions/${sessionId}/thumbsup_counter/${shardId}
number of shard.I want to try Plan2.
Like this.
sessions/${sessionId}/thumbsup_counter/1
shards : 9
sessions/${sessionId}/thumbsup_counter/2
shards : 11
sessions/${sessionId}/thumbsup_counter/3
shards : 10
OK π
I'll fix the code as soon as possible.
After tapped thumbs-up button, the app should update the thumbs-up count.
Can I use the realtime update function with firestore?
I think that the app is able to update automatically the count when other users tap thumbs-up button of the same session. π€
Get realtime updates with Cloud Firestore Β |Β Firebase
https://firebase.google.com/docs/firestore/query-data/listen?hl=en
And I want to implement extensions for Kotlin Coroutines Flow if I adopt the realtime update. π€π€
I think so too. π
The favorite actually does the same thing except that there are multiple shards.
https://github.com/droidkaigi/conference-app-2020/blob/master/data/firestore/src/main/java/io/github/droidkaigi/confsched2020/data/firestore/internal/FirestoreImpl.kt#L38
Oh, sorry.
I missed it.π
Thanks!!
@takahirom
I'm debugging to retrieve shards of thumbs-up counter.
I caught a permission error like this.
2020-02-02 03:05:28.280 4036-4106/io.github.droidkaigi.confsched2020.debug W/Firestore: (20.2.0) [Firestore]: Listen for Query(confsched/2020/sessions/155510/thumbsup_counter order by __name__) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
2020-02-02 03:05:28.499 4036-4036/io.github.droidkaigi.confsched2020.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.github.droidkaigi.confsched2020.debug, PID: 4036
com.google.firebase.firestore.FirebaseFirestoreException: PERMISSION_DENIED: Missing or insufficient permissions.
at com.google.firebase.firestore.util.Util.exceptionFromStatus(com.google.firebase:firebase-firestore@@20.2.0:121)
...
While, I probably successed to create shards.
Could you show the security rules of firestore after changing into the single counter way?
I will check today!
Security rules of /thumbsup_counters/{counterId} needs allow read.
thumbsup_counters but allow get allows only single document read requests.allow list allows multiple document read requests.allow read includes get and listNew rulesβ
https://github.com/DroidKaigi/conference-app-2020/pull/626#issuecomment-581129891
Discussion of changing rules β
https://twitter.com/mk_mkee/status/1223922969124040704?s=20
Thank you takahirom san!
When does the app show outlined button?

Now the app show contained button if thumbs-up count is zero.

I talked with designer π
0 = white
1 or more(all people) = blue.
request.resource.data.shards > resource.data.shards &&
request.resource.data.shards < resource.data.shards + 51
debounce operator like Rx
Most helpful comment
OK π
I'll fix the code as soon as possible.