From d3aacee2354b29fd6ce0b4c9f7666c8ba66ae9a8 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Wed, 24 Jun 2026 13:32:19 +0300 Subject: [PATCH] Fix `test_update_profile_set_field_writes_to_per_user_profile_tracking_table` test And remove unused `get_profile_updates_per_user_for_user` function --- synapse/storage/databases/main/profile.py | 34 ----------- tests/handlers/test_profile.py | 69 +++++++++++++++++++---- 2 files changed, 57 insertions(+), 46 deletions(-) diff --git a/synapse/storage/databases/main/profile.py b/synapse/storage/databases/main/profile.py index 3a8a54da5e..1bbc1593f6 100644 --- a/synapse/storage/databases/main/profile.py +++ b/synapse/storage/databases/main/profile.py @@ -672,40 +672,6 @@ class ProfileWorkerStore(SQLBaseStore): _track_profile_updates_per_user_txn, ) - async def get_profile_updates_per_user_for_user( - self, *, from_id: int, to_id: int, user_id: str - ) -> list[int]: - """ - Get profile updates per user stream ID's for a particular user. - - Args: - from_id: The starting stream ID (exclusive) - to_id: The ending stream ID (inclusive) - user_id: The full user ID to filter on - - Returns: - List of stream ID's. - """ - - def _get_profile_updates_per_user_for_user_txn( - txn: LoggingTransaction, - ) -> list[int]: - sql = """ - SELECT - stream_id - FROM profile_updates_per_user - WHERE - ? < stream_id AND stream_id <= ? AND user_id = ? - """ - txn.execute(sql, (from_id, to_id, user_id)) - rows = cast(list[tuple[int]], txn.fetchall()) - return [row[0] for row in rows] - - return await self.db_pool.runInteraction( - "get_profile_updates_per_user_for_user", - _get_profile_updates_per_user_for_user_txn, - ) - async def create_profile(self, user_id: UserID) -> None: """ Create a blank profile for a user. diff --git a/tests/handlers/test_profile.py b/tests/handlers/test_profile.py index 5267a6ab3b..00b0aca565 100644 --- a/tests/handlers/test_profile.py +++ b/tests/handlers/test_profile.py @@ -339,29 +339,74 @@ class ProfileTestCase(unittest.HomeserverTestCase): ) ) per_user_updates = self.get_success( - self.store.get_profile_updates_per_user_for_user( - from_id=1, - to_id=2, + self.store.get_profile_updates_for_user_and_fields( + from_id=0, + to_id=10, user_id="@roger:test", + field_names={"m.status"}, ) ) - self.assertEqual(per_user_updates, [2]) + self.assertEqual( + per_user_updates, + [ + ProfileUpdate( + stream_id=4, + user_id="@millie:test", + action="joined_room", + field_name=None, + ), + ProfileUpdate( + stream_id=5, + user_id=self.frank.to_string(), + action="update", + field_name="m.status", + ), + ], + ) per_user_updates = self.get_success( - self.store.get_profile_updates_per_user_for_user( - from_id=1, - to_id=2, + self.store.get_profile_updates_for_user_and_fields( + from_id=0, + to_id=10, user_id="@millie:test", + field_names={"m.status"}, ) ) - self.assertEqual(per_user_updates, [2]) + self.assertEqual( + per_user_updates, + [ + ProfileUpdate( + stream_id=5, + user_id=self.frank.to_string(), + action="update", + field_name="m.status", + ), + ], + ) per_user_updates = self.get_success( - self.store.get_profile_updates_per_user_for_user( - from_id=1, - to_id=2, + self.store.get_profile_updates_for_user_and_fields( + from_id=0, + to_id=10, user_id=self.frank.to_string(), + field_names={"m.status"}, ) ) - self.assertEqual(per_user_updates, []) + self.assertEqual( + per_user_updates, + [ + ProfileUpdate( + stream_id=3, + user_id="@roger:test", + action="joined_room", + field_name=None, + ), + ProfileUpdate( + stream_id=4, + user_id="@millie:test", + action="joined_room", + field_name=None, + ), + ], + ) @parameterized.expand( [