diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-03-01 23:20:54 +0000 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-03-05 14:37:23 +0000 |
commit | f8bfcd7e0d2fc6399eb654a41773cd603b4037fc (patch) | |
tree | a1017cd9a4e251d9f70292c24a8b76f529bf4a6f /synapse/storage/stream.py | |
parent | Merge pull request #2943 from matrix-org/rav/fix_find_first_stream_ordering_a... (diff) | |
download | synapse-f8bfcd7e0d2fc6399eb654a41773cd603b4037fc.tar.xz |
Provide a means to pass a timestamp to purge_history
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/stream.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index a2527d2a36..515a04699a 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -416,6 +416,33 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): "get_recent_events_for_room", get_recent_events_for_room_txn ) + def get_room_event_after_stream_ordering(self, room_id, stream_ordering): + """Gets details of the first event in a room at or after a stream ordering + + Args: + room_id (str): + stream_ordering (int): + + Returns: + Deferred[(int, int, str)]: + (stream ordering, topological ordering, event_id) + """ + def _f(txn): + sql = ( + "SELECT stream_ordering, topological_ordering, event_id" + " FROM events" + " WHERE room_id = ? AND stream_ordering >= ?" + " AND NOT outlier" + " ORDER BY stream_ordering" + " LIMIT 1" + ) + txn.execute(sql, (room_id, stream_ordering, )) + return txn.fetchone() + + return self.runInteraction( + "get_room_event_after_stream_ordering", _f, + ) + @defer.inlineCallbacks def get_room_events_max_id(self, room_id=None): """Returns the current token for rooms stream. |