diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-11-12 19:01:18 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-11-13 16:23:00 +0000 |
commit | 55163a0c80fbbc8b3ed35673e89f59f4546eb18c (patch) | |
tree | e696886d4cc399a0d8486c128eee8722c3346352 | |
parent | Implement locally rescinding a federated knock (diff) | |
download | synapse-55163a0c80fbbc8b3ed35673e89f59f4546eb18c.tar.xz |
Add knock membership events to stats generation
-rw-r--r-- | synapse/handlers/stats.py | 5 | ||||
-rw-r--r-- | synapse/storage/databases/main/schema/delta/58/24add_knock_members_to_stats.sql | 17 | ||||
-rw-r--r-- | synapse/storage/databases/main/stats.py | 1 |
3 files changed, 23 insertions, 0 deletions
diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py index dc62b21c06..3961f727aa 100644 --- a/synapse/handlers/stats.py +++ b/synapse/handlers/stats.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # Copyright 2018 New Vector Ltd +# Copyright 2020 Sorunome # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -225,6 +226,8 @@ class StatsHandler: room_stats_delta["left_members"] -= 1 elif prev_membership == Membership.BAN: room_stats_delta["banned_members"] -= 1 + elif prev_membership == Membership.KNOCK: + room_stats_delta["knocked_members"] -= 1 else: raise ValueError( "%r is not a valid prev_membership" % (prev_membership,) @@ -246,6 +249,8 @@ class StatsHandler: room_stats_delta["left_members"] += 1 elif membership == Membership.BAN: room_stats_delta["banned_members"] += 1 + elif membership == Membership.KNOCK: + room_stats_delta["knocked_members"] += 1 else: raise ValueError("%r is not a valid membership" % (membership,)) diff --git a/synapse/storage/databases/main/schema/delta/58/24add_knock_members_to_stats.sql b/synapse/storage/databases/main/schema/delta/58/24add_knock_members_to_stats.sql new file mode 100644 index 0000000000..0c098fbcbc --- /dev/null +++ b/synapse/storage/databases/main/schema/delta/58/24add_knock_members_to_stats.sql @@ -0,0 +1,17 @@ +/* Copyright 2020 Sorunome + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +ALTER TABLE room_stats_current ADD knock_members INT NOT NULL DEFAULT '0'; +ALTER TABLE room_stats_historical ADD knock_members BIGINT NOT NULL DEFAULT '0'; diff --git a/synapse/storage/databases/main/stats.py b/synapse/storage/databases/main/stats.py index 0cdb3ec1f7..62b7551517 100644 --- a/synapse/storage/databases/main/stats.py +++ b/synapse/storage/databases/main/stats.py @@ -41,6 +41,7 @@ ABSOLUTE_STATS_FIELDS = { "current_state_events", "joined_members", "invited_members", + "knocked_members", "left_members", "banned_members", "local_users_in_room", |