trying to get only messages with listen count not high

This commit is contained in:
talksik
2021-12-21 15:06:00 -08:00
parent da80e1f77d
commit c248578bc3
2 changed files with 2 additions and 4 deletions
@@ -107,9 +107,7 @@ class FirestoreService {
func getFirestoreServerTimestamp() -> FieldValue { func getFirestoreServerTimestamp() -> FieldValue {
return FieldValue.serverTimestamp() return FieldValue.serverTimestamp()
} }
func createOrUpdateUserFriends(userFriend: UserFriends, completion: @escaping((_ state: ServiceState) -> ())) { func createOrUpdateUserFriends(userFriend: UserFriends, completion: @escaping((_ state: ServiceState) -> ())) {
do { do {
let userFriendCollection = db.collection(Collection.userFriends.rawValue) let userFriendCollection = db.collection(Collection.userFriends.rawValue)
+1 -1
View File
@@ -283,7 +283,7 @@ extension AuthSessionStore {
// order: sent time should make it easy to add to dict // order: sent time should make it easy to add to dict
// limit: because each user should have most 12 friends and so would at most need 24 messages to show turns and all that...save myself from hackers here // limit: because each user should have most 12 friends and so would at most need 24 messages to show turns and all that...save myself from hackers here
// TODO: use the indexes I created // TODO: use the indexes I created
db.collection("messages").whereField("receiverId", isEqualTo: userId).limit(to: 100) db.collection("messages").whereField("receiverId", isEqualTo: userId).whereField("listenCount", isLessThanOrEqualTo: 1).limit(to: 100)
.addSnapshotListener { querySnapshot, error in .addSnapshotListener { querySnapshot, error in
guard let documents = querySnapshot?.documents else { guard let documents = querySnapshot?.documents else {
print("Error fetching messages: \(error!)") print("Error fetching messages: \(error!)")