Order things correctly

This commit is contained in:
Erik Johnston 2016-02-01 16:32:46 +00:00
parent 4bf448be25
commit 89b40b225c
2 changed files with 5 additions and 1 deletions

View File

@ -1022,7 +1022,7 @@ class RoomEventSource(object):
events = list(room_events) events = list(room_events)
events.extend(e for evs, _ in room_to_events.values() for e in evs) events.extend(e for evs, _ in room_to_events.values() for e in evs)
events.sort(key=lambda e: e.internal_metadata.after) events.sort(key=lambda e: e.internal_metadata.order)
if limit: if limit:
events[:] = events[:limit] events[:] = events[:limit]

View File

@ -598,6 +598,10 @@ class StreamStore(SQLBaseStore):
internal = event.internal_metadata internal = event.internal_metadata
internal.before = str(RoomStreamToken(topo, stream - 1)) internal.before = str(RoomStreamToken(topo, stream - 1))
internal.after = str(RoomStreamToken(topo, stream)) internal.after = str(RoomStreamToken(topo, stream))
internal.order = (
int(topo) if topo else 0,
int(stream),
)
@defer.inlineCallbacks @defer.inlineCallbacks
def get_events_around(self, room_id, event_id, before_limit, after_limit): def get_events_around(self, room_id, event_id, before_limit, after_limit):