Run Black. (#5482)

This commit is contained in:
Amber Brown 2019-06-20 19:32:02 +10:00 committed by GitHub
parent 7dcf984075
commit 32e7c9e7f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
376 changed files with 9142 additions and 10388 deletions

View file

@ -71,7 +71,8 @@ class StatsStore(StateDeltasStore):
# Get all the rooms that we want to process.
def _make_staging_area(txn):
# Create the temporary tables
stmts = get_statements("""
stmts = get_statements(
"""
-- We just recreate the table, we'll be reinserting the
-- correct entries again later anyway.
DROP TABLE IF EXISTS {temp}_rooms;
@ -85,7 +86,10 @@ class StatsStore(StateDeltasStore):
ON {temp}_rooms(events);
CREATE INDEX {temp}_rooms_id
ON {temp}_rooms(room_id);
""".format(temp=TEMP_TABLE).splitlines())
""".format(
temp=TEMP_TABLE
).splitlines()
)
for statement in stmts:
txn.execute(statement)
@ -105,7 +109,9 @@ class StatsStore(StateDeltasStore):
LEFT JOIN room_stats_earliest_token AS t USING (room_id)
WHERE t.room_id IS NULL
GROUP BY c.room_id
""" % (TEMP_TABLE,)
""" % (
TEMP_TABLE,
)
txn.execute(sql)
new_pos = yield self.get_max_stream_id_in_current_state_deltas()
@ -184,7 +190,8 @@ class StatsStore(StateDeltasStore):
logger.info(
"Processing the next %d rooms of %d remaining",
len(rooms_to_work_on), progress["remaining"],
len(rooms_to_work_on),
progress["remaining"],
)
# Number of state events we've processed by going through each room
@ -204,10 +211,17 @@ class StatsStore(StateDeltasStore):
avatar_id = current_state_ids.get((EventTypes.RoomAvatar, ""))
canonical_alias_id = current_state_ids.get((EventTypes.CanonicalAlias, ""))
state_events = yield self.get_events([
join_rules_id, history_visibility_id, encryption_id, name_id,
topic_id, avatar_id, canonical_alias_id,
])
state_events = yield self.get_events(
[
join_rules_id,
history_visibility_id,
encryption_id,
name_id,
topic_id,
avatar_id,
canonical_alias_id,
]
)
def _get_or_none(event_id, arg):
event = state_events.get(event_id)
@ -271,7 +285,7 @@ class StatsStore(StateDeltasStore):
# We've finished a room. Delete it from the table.
self._simple_delete_one_txn(
txn, TEMP_TABLE + "_rooms", {"room_id": room_id},
txn, TEMP_TABLE + "_rooms", {"room_id": room_id}
)
yield self.runInteraction("update_room_stats", _fetch_data)
@ -338,7 +352,7 @@ class StatsStore(StateDeltasStore):
"name",
"topic",
"avatar",
"canonical_alias"
"canonical_alias",
):
field = fields.get(col)
if field and "\0" in field: