Improvments

anoa/public_rooms_module_api
Mathieu Velten 2023-05-31 16:01:53 +02:00
parent a5c50548b0
commit 86ca31e705
2 changed files with 11 additions and 7 deletions

View File

@ -167,9 +167,11 @@ class RoomListHandler:
last_room_id = batch_token.last_room_id last_room_id = batch_token.last_room_id
last_module_index = batch_token.last_module_index 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 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]] = {} num_joined_members_buckets: Dict[int, List[PublicRoom]] = {}
room_ids_to_module_index: Dict[str, int] = {} room_ids_to_module_index: Dict[str, int] = {}
@ -194,12 +196,14 @@ class RoomListHandler:
self._module_api_callbacks.fetch_public_rooms_callbacks self._module_api_callbacks.fetch_public_rooms_callbacks
): ):
# Ask each module for a list of public rooms given the last_joined_members # Ask each module for a list of public rooms given the last_joined_members
# value from the since token and the probing limit. # value from the since token and the probing limit
module_last_joined_members = None # last_joined_members needs to be reduce by one if this module has already
if last_joined_members is not None: # given its result for last_joined_members
module_last_joined_members = last_joined_members module_last_joined_members = last_joined_members
if last_module_index is not None and module_index < last_module_index: 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_last_joined_members = module_last_joined_members - 1
module_public_rooms = await fetch_public_rooms( module_public_rooms = await fetch_public_rooms(
network_tuple, network_tuple,
search_filter, search_filter,

View File

@ -428,7 +428,7 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
query_args += [last_joined_members] query_args += [last_joined_members]
if last_room_id is not None: 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] query_args += [last_joined_members, last_room_id]
where_clauses.append(clause) where_clauses.append(clause)