summary refs log tree commit diff
path: root/synapse/handlers/room.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-01 13:28:27 +0100
committerErik Johnston <erik@matrix.org>2015-05-01 13:28:36 +0100
commit9060dc6b597cc65bde737b1650424f8c7da327d6 (patch)
tree35eca66e6aee85a16be08b119227ed22c5142b57 /synapse/handlers/room.py
parentThis api now no longer returns an array (diff)
downloadsynapse-9060dc6b597cc65bde737b1650424f8c7da327d6.tar.xz
Change public room list to use defer.gatherResults
Diffstat (limited to '')
-rw-r--r--synapse/handlers/room.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index 47456a28e9..bd7a2a592e 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -529,11 +529,19 @@ class RoomListHandler(BaseHandler):
     @defer.inlineCallbacks
     def get_public_room_list(self):
         chunk = yield self.store.get_rooms(is_public=True)
-        for room in chunk:
-            joined_users = yield self.store.get_users_in_room(
-                room_id=room["room_id"],
-            )
-            room["num_joined_members"] = len(joined_users)
+        results = yield defer.gatherResults(
+            [
+                self.store.get_users_in_room(
+                    room_id=room["room_id"],
+                )
+                for room in chunk
+            ],
+            consumeErrors=True,
+        )
+
+        for i, room in enumerate(chunk):
+            room["num_joined_members"] = len(len(results[i]))
+
         # FIXME (erikj): START is no longer a valid value
         defer.returnValue({"start": "START", "end": "END", "chunk": chunk})