diff options
author | Olivier Wilkinson (reivilibre) <olivier@librepush.net> | 2019-08-30 14:36:18 +0100 |
---|---|---|
committer | Olivier Wilkinson (reivilibre) <olivier@librepush.net> | 2019-08-30 14:36:18 +0100 |
commit | 893729a3a6bc0cff6cc803206e413bf746520371 (patch) | |
tree | 6cf7de355151e3c40250c67cd9b7d6e6ceb34769 /synapse/storage/stats.py | |
parent | Add stats regenerator (diff) | |
download | synapse-893729a3a6bc0cff6cc803206e413bf746520371.tar.xz |
Code formatting
Signed-off-by: Olivier Wilkinson (reivilibre) <olivier@librepush.net>
Diffstat (limited to 'synapse/storage/stats.py')
-rw-r--r-- | synapse/storage/stats.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py index 58aa8a7e49..9386e9e150 100644 --- a/synapse/storage/stats.py +++ b/synapse/storage/stats.py @@ -17,15 +17,12 @@ import logging from itertools import chain -from synapse.storage.prepare_database import get_statements - -from synapse.storage.engines import Sqlite3Engine from twisted.internet import defer - -from synapse.api.constants import Membership, EventTypes from twisted.internet.defer import DeferredLock +from synapse.api.constants import EventTypes, Membership from synapse.storage import PostgresEngine +from synapse.storage.engines import Sqlite3Engine from synapse.storage.state_deltas import StateDeltasStore from synapse.util.caches.descriptors import cached @@ -189,15 +186,20 @@ class StatsStore(StateDeltasStore): table, id_col = TYPE_TO_TABLE[stats_type] origin_table = TYPE_TO_ORIGIN_TABLE[stats_type] - zero_cols = list(chain(ABSOLUTE_STATS_FIELDS[stats_type], PER_SLICE_FIELDS[stats_type])) + zero_cols = list( + chain(ABSOLUTE_STATS_FIELDS[stats_type], PER_SLICE_FIELDS[stats_type]) + ) - txn.execute(sql % { - "table": table, - "id_col": id_col, - "origin_table": origin_table, - "zero_cols": zero_cols, - "zeroes": ", ".join(["0"] * len(zero_cols)) - }) + txn.execute( + sql + % { + "table": table, + "id_col": id_col, + "origin_table": origin_table, + "zero_cols": zero_cols, + "zeroes": ", ".join(["0"] * len(zero_cols)), + } + ) def _delete_dirty_skeletons(txn): """ @@ -493,7 +495,7 @@ class StatsStore(StateDeltasStore): room_id, { "total_events": room_total_event_count, - "total_event_bytes": room_total_event_bytes + "total_event_bytes": room_total_event_bytes, }, complete_with_stream_id=current_token, absolute_field_overrides={ @@ -503,9 +505,7 @@ class StatsStore(StateDeltasStore): # tables. "current_state_events": current_state_events, "joined_members": membership_counts.get(Membership.JOIN, 0), - "invited_members": membership_counts.get( - Membership.INVITE, 0 - ), + "invited_members": membership_counts.get(Membership.INVITE, 0), "left_members": membership_counts.get(Membership.LEAVE, 0), "banned_members": membership_counts.get(Membership.BAN, 0), }, @@ -1072,6 +1072,8 @@ class StatsStore(StateDeltasStore): WHERE room_id = ? AND ? <= stream_ordering AND stream_ordering <= ? - """ % (bytes_expression,) + """ % ( + bytes_expression, + ) txn.execute(sql, (room_id, low_token, high_token)) return txn.fetchone() |