From 8a64d8ef063c05ebd500095cf7fd69c7100ff21f Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 22 May 2018 14:16:53 -0700 Subject: [PATCH] populate_db: Fix stream colors being generated wrong. Previously, the stream colors index i was accidentally a function only of the user, so each user got the same color for all their streams. This should provide a lot nicer-looking development environment experience. --- zilencer/management/commands/populate_db.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index f2ab0113bc..ca0e0fde93 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -257,29 +257,30 @@ class Command(BaseCommand): 'polonius@zulip.com': ['Verona'], } - for i, profile in enumerate(profiles): + for profile in profiles: if profile.email not in subscriptions_map: raise Exception('Subscriptions not listed for user %s' % (profile.email,)) for stream_name in subscriptions_map[profile.email]: stream = Stream.objects.get(name=stream_name) r = Recipient.objects.get(type=Recipient.STREAM, type_id=stream.id) - color = STREAM_ASSIGNMENT_COLORS[i % len(STREAM_ASSIGNMENT_COLORS)] - subscriptions_list.append((profile, r, color)) + subscriptions_list.append((profile, r)) else: for i, profile in enumerate(profiles): # Subscribe to some streams. for type_id in recipient_streams[:int(len(recipient_streams) * float(i)/len(profiles)) + 1]: r = Recipient.objects.get(type=Recipient.STREAM, type_id=type_id) - color = STREAM_ASSIGNMENT_COLORS[i % len(STREAM_ASSIGNMENT_COLORS)] - subscriptions_list.append((profile, r, color)) + subscriptions_list.append((profile, r)) subscriptions_to_add = [] # type: List[Subscription] event_time = timezone_now() all_subscription_logs = [] # type: (List[RealmAuditLog]) - for profile, recipient, color in subscriptions_list: + i = 0 + for profile, recipient in subscriptions_list: + i += 1 + color = STREAM_ASSIGNMENT_COLORS[i % len(STREAM_ASSIGNMENT_COLORS)] s = Subscription( recipient=recipient, user_profile=profile,