Allow background tasks to be run on a separate worker. (#8369)

This commit is contained in:
Patrick Cloke 2020-10-02 08:23:15 -04:00 committed by GitHub
parent 462e681c79
commit 62894673e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 537 additions and 449 deletions

View file

@ -192,6 +192,18 @@ class RoomWorkerStore(SQLBaseStore):
"count_public_rooms", _count_public_rooms_txn
)
async def get_room_count(self) -> int:
"""Retrieve the total number of rooms.
"""
def f(txn):
sql = "SELECT count(*) FROM rooms"
txn.execute(sql)
row = txn.fetchone()
return row[0] or 0
return await self.db_pool.runInteraction("get_rooms", f)
async def get_largest_public_rooms(
self,
network_tuple: Optional[ThirdPartyInstanceID],
@ -1292,18 +1304,6 @@ class RoomStore(RoomBackgroundUpdateStore, RoomWorkerStore, SearchStore):
)
self.hs.get_notifier().on_new_replication_data()
async def get_room_count(self) -> int:
"""Retrieve the total number of rooms.
"""
def f(txn):
sql = "SELECT count(*) FROM rooms"
txn.execute(sql)
row = txn.fetchone()
return row[0] or 0
return await self.db_pool.runInteraction("get_rooms", f)
async def add_event_report(
self,
room_id: str,