performance: Avoid Recipient lookup.

We don't have to go to the database to get the Recipient
fields for `user_profile.recipient`.

See also 85ed6f332a from a little
over a year ago--it's very similar.
This commit is contained in:
Steve Howell
2021-12-27 12:27:30 +00:00
committed by Tim Abbott
parent 01ebb2c85f
commit 1e4593b2ae
3 changed files with 7 additions and 3 deletions

View File

@@ -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