Skip to content
Snippets Groups Projects
Commit 06a14876 authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Add find_first_stream_ordering_after_ts

Expose this as a public function which can be called outside a txn
parent 9e08a93a
No related branches found
No related tags found
No related merge requests found
......@@ -489,6 +489,27 @@ class EventPushActionsWorkerStore(SQLBaseStore):
self.stream_ordering_day_ago
)
def find_first_stream_ordering_after_ts(self, ts):
"""Gets the stream ordering corresponding to a given timestamp.
Specifically, finds the stream_ordering of the first event that was
received after the timestamp. This is done by a binary search on the
events table, since there is no index on received_ts, so is
relatively slow.
Args:
ts (int): timestamp in millis
Returns:
Deferred[int]: stream ordering of the first event received after
the timestamp
"""
return self.runInteraction(
"_find_first_stream_ordering_after_ts_txn",
self._find_first_stream_ordering_after_ts_txn,
ts,
)
def _find_first_stream_ordering_after_ts_txn(self, txn, ts):
"""
Find the stream_ordering of the first event that was received after
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment