From b671e577595215ef78f385c4abfdaa6ab46dc189 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 21 May 2018 17:41:10 +0100 Subject: Implement pagination using chunks --- synapse/handlers/room.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'synapse/handlers/room.py') diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index b5850db42f..d627b6db13 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -534,7 +534,7 @@ class RoomEventSource(object): @defer.inlineCallbacks def get_pagination_rows(self, user, config, key): - events, next_key = yield self.store.paginate_room_events( + events, next_key, _ = yield self.store.paginate_room_events( room_id=key, from_key=config.from_key, to_key=config.to_key, -- cgit 1.5.1 From 9e7cf48461ac773cb6661465ab9cf0cf7a190c8d Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 1 Jun 2018 11:51:11 +0100 Subject: Reuse stream_ordering attribute instead of order The internal metadata "order" attribute was only used in one place, which was equivalent to using the stream ordering anyway. --- synapse/handlers/room.py | 3 ++- synapse/storage/stream.py | 11 +++-------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'synapse/handlers/room.py') diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index d627b6db13..870dbd3799 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -514,7 +514,8 @@ class RoomEventSource(object): events = list(room_events) events.extend(e for evs, _ in room_to_events.values() for e in evs) - events.sort(key=lambda e: e.internal_metadata.order) + # Order by the stream ordering of the events. + events.sort(key=lambda e: e.internal_metadata.stream_ordering) if limit: events[:] = events[:limit] diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index baf3715c28..d46672aa4a 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -543,20 +543,15 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): stream = row.stream_ordering internal = event.internal_metadata + + internal.stream_ordering = stream + if topo_order: internal.before = str(RoomStreamToken(chunk, topo, stream - 1)) internal.after = str(RoomStreamToken(chunk, topo, stream)) - internal.order = ( - int(chunk) if chunk else 0, - int(topo) if topo else 0, - int(stream), - ) else: internal.before = str(RoomStreamToken(None, None, stream - 1)) internal.after = str(RoomStreamToken(None, None, stream)) - internal.order = ( - 0, 0, int(stream), - ) @defer.inlineCallbacks def get_events_around(self, room_id, event_id, before_limit, after_limit): -- cgit 1.5.1