mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-29 05:38:26 +00:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user