mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
refactor: Eliminate new_subs.
We now just process new subs for a user immediately within the loop.
This commit is contained in:
@@ -2827,7 +2827,7 @@ def bulk_add_subscriptions(streams: Iterable[Stream],
|
||||
|
||||
already_subscribed: List[Tuple[UserProfile, Stream]] = []
|
||||
subs_to_activate: List[Tuple[Subscription, Stream]] = []
|
||||
new_subs: List[Tuple[UserProfile, int, Stream]] = []
|
||||
subs_to_add: List[Tuple[Subscription, Stream]] = []
|
||||
for user_profile in users:
|
||||
needs_new_sub: Set[int] = set(recipient_ids)
|
||||
for sub in subs_by_user[user_profile.id]:
|
||||
@@ -2841,21 +2841,19 @@ def bulk_add_subscriptions(streams: Iterable[Stream],
|
||||
# pick_color will consider this to be an active
|
||||
# subscription when picking colors
|
||||
sub.active = True
|
||||
|
||||
for recipient_id in needs_new_sub:
|
||||
stream = stream_map[recipient_id]
|
||||
new_subs.append((user_profile, recipient_id, stream))
|
||||
|
||||
subs_to_add: List[Tuple[Subscription, Stream]] = []
|
||||
for (user_profile, recipient_id, stream) in new_subs:
|
||||
if stream.name in color_map:
|
||||
color = color_map[stream.name]
|
||||
else:
|
||||
color = pick_color(user_profile, subs_by_user[user_profile.id])
|
||||
if stream.name in color_map:
|
||||
color = color_map[stream.name]
|
||||
else:
|
||||
color = pick_color(user_profile, subs_by_user[user_profile.id])
|
||||
|
||||
sub_to_add = Subscription(user_profile=user_profile, active=True,
|
||||
color=color, recipient_id=recipient_id)
|
||||
subs_by_user[user_profile.id].append(sub_to_add)
|
||||
subs_to_add.append((sub_to_add, stream))
|
||||
sub_to_add = Subscription(user_profile=user_profile, active=True,
|
||||
color=color, recipient_id=recipient_id)
|
||||
subs_by_user[user_profile.id].append(sub_to_add)
|
||||
subs_to_add.append((sub_to_add, stream))
|
||||
|
||||
new_occupied_streams = bulk_add_subs_to_db_with_logging(
|
||||
realm=realm,
|
||||
|
||||
Reference in New Issue
Block a user