Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Refactor get_recent_events_for_room return type #3198

Merged
merged 4 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions synapse/handlers/initial_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def handle_room(event):
self.store, user_id, messages
)

start_token = now_token.copy_and_replace("room_key", token[0])
end_token = now_token.copy_and_replace("room_key", token[1])
start_token = now_token.copy_and_replace("room_key", token)
end_token = now_token.copy_and_replace("room_key", room_end_token)
time_now = self.clock.time_msec()

d["messages"] = {
Expand Down Expand Up @@ -325,8 +325,8 @@ def _room_initial_sync_parted(self, user_id, room_id, pagin_config,
self.store, user_id, messages, is_peeking=is_peeking
)

start_token = StreamToken.START.copy_and_replace("room_key", token[0])
end_token = StreamToken.START.copy_and_replace("room_key", token[1])
start_token = StreamToken.START.copy_and_replace("room_key", token)
end_token = StreamToken.START.copy_and_replace("room_key", stream_token)

time_now = self.clock.time_msec()

Expand Down Expand Up @@ -409,7 +409,7 @@ def get_receipts():
)

start_token = now_token.copy_and_replace("room_key", token[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/token[0]/token ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scary that that is not picked up by a sytest :(

end_token = now_token.copy_and_replace("room_key", token[1])
end_token = now_token

time_now = self.clock.time_msec()

Expand Down
2 changes: 1 addition & 1 deletion synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def get_state_at(self, room_id, stream_position):
Returns:
A Deferred map from ((type, state_key)->Event)
"""
last_events, token = yield self.store.get_recent_events_for_room(
last_events, _ = yield self.store.get_recent_events_for_room(
room_id, end_token=stream_position.room_key, limit=1,
)

Expand Down
16 changes: 15 additions & 1 deletion synapse/storage/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ def f(txn):

@defer.inlineCallbacks
def get_recent_events_for_room(self, room_id, limit, end_token):
"""Get the most recent events in the room in topological ordering.

Args:
room_id (str)
limit (int)
end_token (str): The stream token representing now.

Returns:
Deferred[tuple[list[FrozenEvent], str]]: Returns a list of
events and a token pointint to the start of the returned
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointint

events.
The events returned are in ascending order.
"""

rows, token = yield self.get_recent_event_ids_for_room(
room_id, limit, end_token,
)
Expand All @@ -372,7 +386,7 @@ def get_recent_events_for_room(self, room_id, limit, end_token):

self._set_before_and_after(events, rows)

defer.returnValue((events, (token, end_token)))
defer.returnValue((events, token))

@defer.inlineCallbacks
def get_recent_event_ids_for_room(self, room_id, limit, end_token):
Expand Down