Compare commits

...

3 Commits

Author SHA1 Message Date
Andrew Morgan 791a7539b2 Add a period to the changelog 2020-09-28 17:43:28 +01:00
Will Hunt f0d1109109 (now working) fix sql statement 2020-09-28 17:26:20 +01:00
Will Hunt 419dbd7d8e changelog 2020-09-28 17:14:04 +01:00
3 changed files with 11 additions and 4 deletions

1
changelog.d/8404.misc Normal file
View File

@ -0,0 +1 @@
Do not include appservice users when calculating the total MAU for a server.

View File

@ -45,7 +45,9 @@ class MonthlyActiveUsersWorkerStore(SQLBaseStore):
sql = """
SELECT COALESCE(count(*), 0)
FROM monthly_active_users
INNER JOIN users ON monthly_active_users.user_id=users.name AND appservice_id IS NULL;
LEFT JOIN users
ON monthly_active_users.user_id=users.name
WHERE (users.appservice_id IS NULL OR users.appservice_id = '');
"""
txn.execute(sql)
(count,) = txn.fetchone()

View File

@ -138,11 +138,15 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
self.assertEqual(count, 1)
def test_appservice_user_not_counted_in_mau(self):
self.get_success(self.store.register_user(user_id="@appservice_user:server", appservice_id="wibble"))
self.get_success(
self.store.register_user(
user_id="@appservice_user:server", appservice_id="wibble"
)
)
count = self.get_success(self.store.get_monthly_active_count())
self.assertEqual(count, 0)
d = self.store.upsert_monthly_active_user("@user:server")
d = self.store.upsert_monthly_active_user("@appservice_user:server")
self.get_success(d)
count = self.get_success(self.store.get_monthly_active_count())
@ -394,7 +398,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
self.get_success(self.store.upsert_monthly_active_user(appservice2_user1))
count = self.get_success(self.store.get_monthly_active_count())
self.assertEqual(count, 4)
self.assertEqual(count, 1)
d = self.store.get_monthly_active_count_by_service()
result = self.get_success(d)