summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathieu Velten <mathieuv@matrix.org>2023-05-31 16:01:53 +0200
committerMathieu Velten <mathieuv@matrix.org>2023-05-31 16:03:57 +0200
commit86ca31e705d3a4735063ce4f203b10b2ed94344f (patch)
treec4e37d9bb2e18b1dec2d5c0d33fa15eafbb2840c
parentSimplify code (diff)
downloadsynapse-86ca31e705d3a4735063ce4f203b10b2ed94344f.tar.xz
Improvments
-rw-r--r--synapse/handlers/room_list.py16
-rw-r--r--synapse/storage/databases/main/room.py2
2 files changed, 11 insertions, 7 deletions
diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py

index 664bfbdacf..6cec313bf4 100644 --- a/synapse/handlers/room_list.py +++ b/synapse/handlers/room_list.py
@@ -167,9 +167,11 @@ class RoomListHandler: last_room_id = batch_token.last_room_id last_module_index = batch_token.last_module_index - # we request one more than wanted to see if there are more pages to come + # We request one more than wanted to see if there are more pages to come probing_limit = limit + 1 if limit is not None else None + # We bucket results per joined members number since we want to keep order + # per joined members number num_joined_members_buckets: Dict[int, List[PublicRoom]] = {} room_ids_to_module_index: Dict[str, int] = {} @@ -194,12 +196,14 @@ class RoomListHandler: self._module_api_callbacks.fetch_public_rooms_callbacks ): # Ask each module for a list of public rooms given the last_joined_members - # value from the since token and the probing limit. - module_last_joined_members = None - if last_joined_members is not None: - module_last_joined_members = last_joined_members - if last_module_index is not None and module_index < last_module_index: + # value from the since token and the probing limit + # last_joined_members needs to be reduce by one if this module has already + # given its result for last_joined_members + module_last_joined_members = last_joined_members + if module_last_joined_members is not None and last_module_index is not None: + if module_index < last_module_index: module_last_joined_members = module_last_joined_members - 1 + module_public_rooms = await fetch_public_rooms( network_tuple, search_filter, diff --git a/synapse/storage/databases/main/room.py b/synapse/storage/databases/main/room.py
index 932293ef2e..80bf35201a 100644 --- a/synapse/storage/databases/main/room.py +++ b/synapse/storage/databases/main/room.py
@@ -428,7 +428,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore): query_args += [last_joined_members] if last_room_id is not None: - clause += f" AND (joined_members {comp} ? OR room_id {comp} ?)" + clause += f" OR (joined_members == ? AND room_id {comp} ?)" query_args += [last_joined_members, last_room_id] where_clauses.append(clause)