mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Merge pull request #635 from matrix-org/erikj/sync_order
Use topological orders for initial sync timeline
This commit is contained in:
commit
58443a022d
@ -184,6 +184,9 @@ class StreamStore(SQLBaseStore):
|
|||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_room_events_stream_for_room(self, room_id, from_key, to_key, limit=0,
|
def get_room_events_stream_for_room(self, room_id, from_key, to_key, limit=0,
|
||||||
order='DESC'):
|
order='DESC'):
|
||||||
|
# Note: If from_key is None then we return in topological order. This
|
||||||
|
# is because in that case we're using this as a "get the last few messages
|
||||||
|
# in a room" function, rather than "get new messages since last sync"
|
||||||
if from_key is not None:
|
if from_key is not None:
|
||||||
from_id = RoomStreamToken.parse_stream_token(from_key).stream
|
from_id = RoomStreamToken.parse_stream_token(from_key).stream
|
||||||
else:
|
else:
|
||||||
@ -217,8 +220,8 @@ class StreamStore(SQLBaseStore):
|
|||||||
" room_id = ?"
|
" room_id = ?"
|
||||||
" AND not outlier"
|
" AND not outlier"
|
||||||
" AND stream_ordering <= ?"
|
" AND stream_ordering <= ?"
|
||||||
" ORDER BY stream_ordering %s LIMIT ?"
|
" ORDER BY topological_ordering %s, stream_ordering %s LIMIT ?"
|
||||||
) % (order,)
|
) % (order, order,)
|
||||||
txn.execute(sql, (room_id, to_id, limit))
|
txn.execute(sql, (room_id, to_id, limit))
|
||||||
|
|
||||||
rows = self.cursor_to_dict(txn)
|
rows = self.cursor_to_dict(txn)
|
||||||
@ -232,7 +235,7 @@ class StreamStore(SQLBaseStore):
|
|||||||
get_prev_content=True
|
get_prev_content=True
|
||||||
)
|
)
|
||||||
|
|
||||||
self._set_before_and_after(ret, rows, topo_order=False)
|
self._set_before_and_after(ret, rows, topo_order=from_id is None)
|
||||||
|
|
||||||
if order.lower() == "desc":
|
if order.lower() == "desc":
|
||||||
ret.reverse()
|
ret.reverse()
|
||||||
|
Loading…
Reference in New Issue
Block a user