From ebb605319b3301bc0230bbef9cb013156d5f6aaa Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 13 Oct 2020 15:10:44 +0000 Subject: [PATCH] refactor: Rename stream_map to recipient_id_to_stream. I want to make a new dict called stream_id_to_stream, and stream_map would be confusing. --- zerver/lib/actions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index feade874aa..2a9b8ebee7 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2826,7 +2826,7 @@ def bulk_add_subscriptions( for user in users: assert user.realm_id == realm.id - stream_map = {stream.recipient_id: stream for stream in streams} + recipient_id_to_stream = {stream.recipient_id: stream for stream in streams} subs_by_user: Dict[int, List[Subscription]] = defaultdict(list) all_subs_query = get_stream_subscriptions_for_users(users).select_related('user_profile') @@ -2848,13 +2848,14 @@ def bulk_add_subscriptions( for sub in my_subs: if sub.recipient_id in new_recipient_ids: new_recipient_ids.remove(sub.recipient_id) + stream = recipient_id_to_stream[sub.recipient_id] if sub.active: - already_subscribed.append((user_profile, stream_map[sub.recipient_id])) + already_subscribed.append((user_profile, stream)) else: - subs_to_activate.append((sub, stream_map[sub.recipient_id])) + subs_to_activate.append((sub, stream)) for recipient_id in new_recipient_ids: - stream = stream_map[recipient_id] + stream = recipient_id_to_stream[recipient_id] if stream.name in color_map: color = color_map[stream.name]