summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/storage/monthly_active_users.py10
-rw-r--r--synapse/storage/schema/delta/51/monthly_active_users.sql4
-rw-r--r--tests/storage/test_monthly_active_users.py6
3 files changed, 7 insertions, 13 deletions
diff --git a/synapse/storage/monthly_active_users.py b/synapse/storage/monthly_active_users.py
index 03eeea792e..7b3f13aedf 100644
--- a/synapse/storage/monthly_active_users.py
+++ b/synapse/storage/monthly_active_users.py
@@ -38,22 +38,18 @@ class MonthlyActiveUsersStore(SQLBaseStore):
             return count
         return self.runInteraction("count_users", _count_users)
 
-    def upsert_monthly_active_user(self, user_id):
+    def insert_monthly_active_user(self, user_id):
         """
             Updates or inserts monthly active user member
             Arguments:
                 user_id (str): user to add/update
         """
-        return self._simple_upsert(
+        return self._simple_insert(
             desc="upsert_monthly_active_user",
             table="monthly_active_users",
-            keyvalues={
-                "user_id": user_id,
-            },
             values={
-                "timestamp": int(self._clock.time_msec()),
+                "user_id": user_id,
             },
-            lock=False,
         )
 
     @defer.inlineCallbacks
diff --git a/synapse/storage/schema/delta/51/monthly_active_users.sql b/synapse/storage/schema/delta/51/monthly_active_users.sql
index f2b6d3e31e..590b1abab2 100644
--- a/synapse/storage/schema/delta/51/monthly_active_users.sql
+++ b/synapse/storage/schema/delta/51/monthly_active_users.sql
@@ -15,9 +15,7 @@
 
 -- a table of monthly active users, for use where blocking based on mau limits
 CREATE TABLE monthly_active_users (
-    user_id TEXT NOT NULL,
-    timestamp BIGINT NOT NULL
+    user_id TEXT NOT NULL
 );
 
 CREATE UNIQUE INDEX monthly_active_users_users ON monthly_active_users(user_id);
-CREATE INDEX monthly_active_users_time_stamp ON monthly_active_users(timestamp);
diff --git a/tests/storage/test_monthly_active_users.py b/tests/storage/test_monthly_active_users.py
index 9b1ffc6369..7a8432ce69 100644
--- a/tests/storage/test_monthly_active_users.py
+++ b/tests/storage/test_monthly_active_users.py
@@ -22,7 +22,7 @@ class MonthlyActiveUsersTestCase(tests.unittest.TestCase):
         count = yield self.mau.get_monthly_active_count()
         self.assertEqual(0, count)
 
-        yield self.mau.upsert_monthly_active_user("@user:server")
+        yield self.mau.insert_monthly_active_user("@user:server")
         count = yield self.mau.get_monthly_active_count()
 
         self.assertEqual(1, count)
@@ -34,8 +34,8 @@ class MonthlyActiveUsersTestCase(tests.unittest.TestCase):
         user_id3 = "@user3:server"
         result = yield self.mau.is_user_monthly_active(user_id1)
         self.assertFalse(result)
-        yield self.mau.upsert_monthly_active_user(user_id1)
-        yield self.mau.upsert_monthly_active_user(user_id2)
+        yield self.mau.insert_monthly_active_user(user_id1)
+        yield self.mau.insert_monthly_active_user(user_id2)
         result = yield self.mau.is_user_monthly_active(user_id1)
         self.assertTrue(result)
         result = yield self.mau.is_user_monthly_active(user_id3)