Pull max id from correct table

This commit is contained in:
Erik Johnston 2017-05-31 15:13:49 +01:00
parent 350622a107
commit dc51af3d03
2 changed files with 10 additions and 4 deletions

View File

@ -111,9 +111,7 @@ class UserDirectoyHandler(object):
"""Populates the user_directory from the current state of the DB, used """Populates the user_directory from the current state of the DB, used
when synapse first starts with user_directory support when synapse first starts with user_directory support
""" """
new_pos = yield self.store.get_max_stream_id_in_current_state_deltas()
# TODO: pull from current delta stream_id
new_pos = self.store.get_room_max_stream_ordering()
# Delete any existing entries just in case there are any # Delete any existing entries just in case there are any
yield self.store.delete_all_from_user_dir() yield self.store.delete_all_from_user_dir()
@ -284,7 +282,7 @@ class UserDirectoyHandler(object):
# is public (i.e. the room_id in the database) # is public (i.e. the room_id in the database)
return return
# TODO: Make this faster? # XXX: Make this faster?
rooms = yield self.store.get_rooms_for_user(user_id) rooms = yield self.store.get_rooms_for_user(user_id)
for j_room_id in rooms: for j_room_id in rooms:
is_public = yield self.store.is_room_world_readable_or_publicly_joinable( is_public = yield self.store.is_room_world_readable_or_publicly_joinable(

View File

@ -195,6 +195,14 @@ class UserDirectoryStore(SQLBaseStore):
"get_current_state_deltas", self.cursor_to_dict, sql, prev_stream_id "get_current_state_deltas", self.cursor_to_dict, sql, prev_stream_id
) )
def get_max_stream_id_in_current_state_deltas(self):
return self._simple_select_one_onecol(
table="current_state_delta_stream",
keyvalues={},
retcol="COALESCE(MAX(stream_id), -1)",
desc="get_max_stream_id_in_current_state_deltas",
)
@defer.inlineCallbacks @defer.inlineCallbacks
def search_user_dir(self, search_term, limit): def search_user_dir(self, search_term, limit):
"""Searches for users in directory """Searches for users in directory