Use up-to-date db interaction method

This commit is contained in:
Eric Eastwood 2021-07-26 22:50:10 -05:00
parent f721899c69
commit af085abbbf

View file

@ -1512,7 +1512,7 @@ class EventsWorkerStore(SQLBaseStore):
_cleanup_old_transaction_ids_txn,
)
def get_event_for_timestamp(self, room_id, timestamp):
async def get_event_for_timestamp(self, room_id, timestamp):
sql_template = """
SELECT event_id, origin_server_ts FROM events
WHERE
@ -1522,7 +1522,7 @@ class EventsWorkerStore(SQLBaseStore):
LIMIT 1;
"""
def f(txn):
def get_event_for_timestamp_txn(txn):
txn.execute(sql_template % ("<=",), (timestamp, room_id))
row = txn.fetchone()
if row:
@ -1549,4 +1549,7 @@ class EventsWorkerStore(SQLBaseStore):
return event_id_after
return self.runInteraction("get_event_for_timestamp", f)
return await self.db_pool.runInteraction(
"get_event_for_timestamp_txn",
get_event_for_timestamp_txn,
)