diff options
author | Erik Johnston <erik@matrix.org> | 2019-05-30 15:22:32 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-05-30 15:25:41 +0100 |
commit | 04710cc2d71127b1f416e87f7a4aea3ce6d93410 (patch) | |
tree | b2765968790f1b8af7c672d4fe563132babf7795 /synapse/storage/stats.py | |
parent | Get events all at once (diff) | |
download | synapse-04710cc2d71127b1f416e87f7a4aea3ce6d93410.tar.xz |
Fetch membership counts all at once
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/stats.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/synapse/storage/stats.py b/synapse/storage/stats.py index 99b4af5555..727f60b3bd 100644 --- a/synapse/storage/stats.py +++ b/synapse/storage/stats.py @@ -226,18 +226,9 @@ class StatsStore(StateDeltasStore): current_token = self._get_max_stream_id_in_current_state_deltas_txn(txn) current_state_events = len(current_state_ids) - joined_members = self._get_user_count_in_room_txn( - txn, room_id, Membership.JOIN - ) - invited_members = self._get_user_count_in_room_txn( - txn, room_id, Membership.INVITE - ) - left_members = self._get_user_count_in_room_txn( - txn, room_id, Membership.LEAVE - ) - banned_members = self._get_user_count_in_room_txn( - txn, room_id, Membership.BAN - ) + + membership_counts = self._get_user_counts_in_room_txn(txn, room_id) + total_state_events = self._get_total_state_event_counts_txn( txn, room_id ) @@ -250,10 +241,10 @@ class StatsStore(StateDeltasStore): { "bucket_size": self.stats_bucket_size, "current_state_events": current_state_events, - "joined_members": joined_members, - "invited_members": invited_members, - "left_members": left_members, - "banned_members": banned_members, + "joined_members": membership_counts.get(Membership.JOIN, 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), "state_events": total_state_events, }, ) |