forked from MirrorHub/synapse
Remove get_room_event_after_stream_ordering entirely
This commit is contained in:
parent
e601f35d3b
commit
842c2cfbf1
2 changed files with 13 additions and 58 deletions
|
@ -107,7 +107,7 @@ class PurgeHistoryRestServlet(RestServlet):
|
||||||
|
|
||||||
stream_ordering = await self.store.find_first_stream_ordering_after_ts(ts)
|
stream_ordering = await self.store.find_first_stream_ordering_after_ts(ts)
|
||||||
|
|
||||||
r = await self.store.get_room_event_after_stream_ordering(
|
r = await self.store.get_room_event_before_stream_ordering(
|
||||||
room_id, stream_ordering
|
room_id, stream_ordering
|
||||||
)
|
)
|
||||||
if not r:
|
if not r:
|
||||||
|
|
|
@ -525,25 +525,6 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
||||||
|
|
||||||
return rows, token
|
return rows, token
|
||||||
|
|
||||||
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)
|
|
||||||
"""
|
|
||||||
return self.db.runInteraction(
|
|
||||||
"get_room_event_after_stream_ordering",
|
|
||||||
self.get_room_event_around_stream_ordering_txn,
|
|
||||||
room_id,
|
|
||||||
stream_ordering,
|
|
||||||
"f",
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_room_event_before_stream_ordering(self, room_id, stream_ordering):
|
def get_room_event_before_stream_ordering(self, room_id, stream_ordering):
|
||||||
"""Gets details of the first event in a room at or before a stream ordering
|
"""Gets details of the first event in a room at or before a stream ordering
|
||||||
|
|
||||||
|
@ -555,45 +536,19 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
||||||
Deferred[(int, int, str)]:
|
Deferred[(int, int, str)]:
|
||||||
(stream ordering, topological ordering, event_id)
|
(stream ordering, topological ordering, event_id)
|
||||||
"""
|
"""
|
||||||
return self.db.runInteraction(
|
def _f(txn):
|
||||||
"get_room_event_before_stream_ordering",
|
sql = (
|
||||||
self.get_room_event_around_stream_ordering_txn,
|
"SELECT stream_ordering, topological_ordering, event_id"
|
||||||
room_id,
|
" FROM events"
|
||||||
stream_ordering,
|
" WHERE room_id = ? AND stream_ordering <= ?"
|
||||||
"b",
|
" AND NOT outlier"
|
||||||
)
|
" ORDER BY stream_ordering DESC"
|
||||||
|
" LIMIT 1"
|
||||||
|
)
|
||||||
|
txn.execute(sql, (room_id, stream_ordering))
|
||||||
|
return txn.fetchone()
|
||||||
|
|
||||||
def get_room_event_around_stream_ordering_txn(
|
return self.db.runInteraction("get_room_event_before_stream_ordering", _f)
|
||||||
self, txn, room_id, stream_ordering, dir="f"
|
|
||||||
):
|
|
||||||
"""Gets details of the first event in a room at or either after or before a
|
|
||||||
stream ordering, depending on the provided direction.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
room_id (str):
|
|
||||||
stream_ordering (int):
|
|
||||||
dir (str): Direction in which we're looking towards in the room's history,
|
|
||||||
either "f" (forward) or "b" (backward).
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Deferred[(int, int, str)]:
|
|
||||||
(stream ordering, topological ordering, event_id)
|
|
||||||
"""
|
|
||||||
# Figure out which comparison operation to perform and how to order the results,
|
|
||||||
# using the provided direction.
|
|
||||||
op = "<=" if dir == "b" else ">="
|
|
||||||
order = "DESC" if dir == "b" else "ASC"
|
|
||||||
|
|
||||||
sql = (
|
|
||||||
"SELECT stream_ordering, topological_ordering, event_id"
|
|
||||||
" FROM events"
|
|
||||||
" WHERE room_id = ? AND stream_ordering %s ?"
|
|
||||||
" AND NOT outlier"
|
|
||||||
" ORDER BY stream_ordering %s"
|
|
||||||
" LIMIT 1"
|
|
||||||
) % (op, order)
|
|
||||||
txn.execute(sql, (room_id, stream_ordering))
|
|
||||||
return txn.fetchone()
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_room_events_max_id(self, room_id=None):
|
def get_room_events_max_id(self, room_id=None):
|
||||||
|
|
Loading…
Reference in a new issue