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

@ -211,11 +211,11 @@ class StatsStore(StateDeltasStore):
return len(rooms_to_work_on)
def get_stats_positions(self):
async def get_stats_positions(self) -> int:
"""
Returns the stats processor positions.
"""
return self.db_pool.simple_select_one_onecol(
return await self.db_pool.simple_select_one_onecol(
table="stats_incremental_position",
keyvalues={},
retcol="stream_id",
@ -300,7 +300,7 @@ class StatsStore(StateDeltasStore):
return slice_list
@cached()
def get_earliest_token_for_stats(self, stats_type, id):
async def get_earliest_token_for_stats(self, stats_type: str, id: str) -> int:
"""
Fetch the "earliest token". This is used by the room stats delta
processor to ignore deltas that have been processed between the
@ -308,11 +308,11 @@ class StatsStore(StateDeltasStore):
being calculated.
Returns:
Deferred[int]
The earliest token.
"""
table, id_col = TYPE_TO_TABLE[stats_type]
return self.db_pool.simple_select_one_onecol(
return await self.db_pool.simple_select_one_onecol(
"%s_current" % (table,),
keyvalues={id_col: id},
retcol="completed_delta_stream_id",