Convert simple_select_one and simple_select_one_onecol to async (#8162)

This commit is contained in:
Patrick Cloke 2020-08-26 07:19:32 -04:00 committed by GitHub
parent 56efa9ec71
commit 4c6c56dc58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 220 additions and 113 deletions

View file

@ -73,15 +73,15 @@ class RoomWorkerStore(SQLBaseStore):
self.config = hs.config
def get_room(self, room_id):
async def get_room(self, room_id: str) -> dict:
"""Retrieve a room.
Args:
room_id (str): The ID of the room to retrieve.
room_id: The ID of the room to retrieve.
Returns:
A dict containing the room information, or None if the room is unknown.
"""
return self.db_pool.simple_select_one(
return await self.db_pool.simple_select_one(
table="rooms",
keyvalues={"room_id": room_id},
retcols=("room_id", "is_public", "creator"),
@ -330,8 +330,8 @@ class RoomWorkerStore(SQLBaseStore):
return ret_val
@cached(max_entries=10000)
def is_room_blocked(self, room_id):
return self.db_pool.simple_select_one_onecol(
async def is_room_blocked(self, room_id: str) -> Optional[bool]:
return await self.db_pool.simple_select_one_onecol(
table="blocked_rooms",
keyvalues={"room_id": room_id},
retcol="1",