diff options
author | Erik Johnston <erik@matrix.org> | 2016-01-28 11:52:34 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-01-28 11:52:34 +0000 |
commit | 4e7948b47a3f197682de82fc0cda07ebb08a581d (patch) | |
tree | 24fa68c563cf92df31240df6a5381f960940828b /synapse/storage | |
parent | Return correct type of token (diff) | |
download | synapse-4e7948b47a3f197682de82fc0cda07ebb08a581d.tar.xz |
Allow paginating backwards from stream token
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/stream.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 28721e6994..5096b46864 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -234,10 +234,10 @@ class StreamStore(SQLBaseStore): get_prev_content=True ) - ret.reverse() - self._set_before_and_after(ret, rows, topo_order=False) + ret.reverse() + if rows: key = "s%d" % min(r["stream_ordering"] for r in rows) else: @@ -570,6 +570,18 @@ class StreamStore(SQLBaseStore): row["topological_ordering"], row["stream_ordering"],) ) + def get_max_topological_token_for_stream_and_room(self, room_id, stream_key): + sql = ( + "SELECT max(topological_ordering) FROM events" + " WHERE room_id = ? AND stream_ordering < ?" + ) + return self._execute( + "get_max_topological_token_for_stream_and_room", None, + sql, room_id, stream_key, + ).addCallback( + lambda r: r[0][0] if r else 0 + ) + def _get_max_topological_txn(self, txn): txn.execute( "SELECT MAX(topological_ordering) FROM events" |