Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

performance: Avoid Recipient lookup.

Steve Howell1e4593b2ae89
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index d02500b1d5d..8ac73fa2d8f 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -2647,7 +2647,11 @@ def get_recipient_from_user_profiles(
assert recipient_profiles_map
if len(recipient_profiles_map) == 1:
[user_profile] = recipient_profiles_map.values()
- return user_profile.recipient
+ return Recipient(
+ id=user_profile.recipient_id,
+ type=Recipient.PERSONAL,
+ type_id=user_profile.id,
+ )
# Otherwise, we need a huddle. Make sure the sender is included in huddle messages
recipient_profiles_map[sender.id] = sender
diff --git a/zerver/tests/test_example.py b/zerver/tests/test_example.py
index d67e72e8a0e..fe3db5b9b2e 100644
--- a/zerver/tests/test_example.py
+++ b/zerver/tests/test_example.py
@@ -376,7 +376,7 @@ class TestQueryCounts(ZulipTestCase):
)
# The assert_length helper is another useful extra from ZulipTestCase.
- self.assert_length(queries, 16)
+ self.assert_length(queries, 15)
class TestDevelopmentEmailsLog(ZulipTestCase):
diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py
index bcda1c3e818..23198d2e77a 100644
--- a/zerver/tests/test_users.py
+++ b/zerver/tests/test_users.py
@@ -799,7 +799,7 @@ class QueryCountTest(ZulipTestCase):
acting_user=None,
)
- self.assert_length(queries, 85)
+ self.assert_length(queries, 84)
self.assert_length(cache_tries, 27)
peer_add_events = [event for event in events if event["event"].get("op") == "peer_add"]