Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
create_user: Rename constants used in 'add_new_user_history'.
Prakhar Pratyushf5a0755f16df
diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.pyindex 134786fe855..ce2214507f1 100644--- a/zerver/actions/create_user.py+++ b/zerver/actions/create_user.py@@ -62,14 +62,14 @@ if settings.BILLING_ENABLED:from corporate.lib.stripe import RealmBillingSession-MAX_NUM_ONBOARDING_MESSAGES = 1000-MAX_NUM_ONBOARDING_UNREAD_MESSAGES = 20+MAX_NUM_RECENT_MESSAGES = 1000+MAX_NUM_RECENT_UNREAD_MESSAGES = 20# We don't want to mark years-old messages as unread, since that might# feel like Zulip is buggy, but in low-traffic or bursty-traffic# organizations, it's reasonable for the most recent 20 messages to be# several weeks old and still be a good place to start.-ONBOARDING_RECENT_TIMEDELTA = timedelta(weeks=12)+RECENT_MESSAGES_TIMEDELTA = timedelta(weeks=12)def send_message_to_signup_notification_stream(@@ -186,7 +186,7 @@ def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -]# Start by finding recent messages matching those recipients.- cutoff_date = timezone_now() - ONBOARDING_RECENT_TIMEDELTA+ cutoff_date = timezone_now() - RECENT_MESSAGES_TIMEDELTArecent_message_ids = set(Message.objects.filter(# Uses index: zerver_message_realm_recipient_id@@ -195,7 +195,7 @@ def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -date_sent__gt=cutoff_date,).order_by("-id")- .values_list("id", flat=True)[0:MAX_NUM_ONBOARDING_MESSAGES]+ .values_list("id", flat=True)[0:MAX_NUM_RECENT_MESSAGES])if len(recent_message_ids) > 0:@@ -212,7 +212,7 @@ def add_new_user_history(user_profile: UserProfile, streams: Iterable[Stream]) -# Find which message ids we should mark as read.# (We don't want too many unread messages.)- older_message_ids = set(backfill_message_ids[:-MAX_NUM_ONBOARDING_UNREAD_MESSAGES])+ older_message_ids = set(backfill_message_ids[:-MAX_NUM_RECENT_UNREAD_MESSAGES])# Create UserMessage rows for the backfill.ums_to_create = []diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 1c59caf9eba..40ab6f504a9 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -254,11 +254,11 @@ class AddNewUserHistoryTest(ZulipTestCase):self.example_user("hamlet"), streams[0].name, "test")- # Overwrite MAX_NUM_ONBOARDING_UNREAD_MESSAGES to 2- MAX_NUM_ONBOARDING_UNREAD_MESSAGES = 2+ # Overwrite MAX_NUM_RECENT_UNREAD_MESSAGES to 2+ MAX_NUM_RECENT_UNREAD_MESSAGES = 2with patch(- "zerver.actions.create_user.MAX_NUM_ONBOARDING_UNREAD_MESSAGES",- MAX_NUM_ONBOARDING_UNREAD_MESSAGES,+ "zerver.actions.create_user.MAX_NUM_RECENT_UNREAD_MESSAGES",+ MAX_NUM_RECENT_UNREAD_MESSAGES,):add_new_user_history(user_profile, streams)@@ -278,7 +278,7 @@ class AddNewUserHistoryTest(ZulipTestCase):).flags.read.is_set)- # Verify that the MAX_NUM_ONBOARDING_UNREAD_MESSAGES latest messages+ # Verify that the MAX_NUM_RECENT_UNREAD_MESSAGES latest messages# that weren't the race message are marked as unread.latest_messages = (UserMessage.objects.filter(@@ -286,7 +286,7 @@ class AddNewUserHistoryTest(ZulipTestCase):message__recipient__type=Recipient.STREAM,).exclude(message_id=race_message_id)- .order_by("-message_id")[0:MAX_NUM_ONBOARDING_UNREAD_MESSAGES]+ .order_by("-message_id")[0:MAX_NUM_RECENT_UNREAD_MESSAGES])self.assert_length(latest_messages, 2)for msg in latest_messages:@@ -300,7 +300,7 @@ class AddNewUserHistoryTest(ZulipTestCase):).exclude(message_id=race_message_id).order_by("-message_id")[- MAX_NUM_ONBOARDING_UNREAD_MESSAGES : MAX_NUM_ONBOARDING_UNREAD_MESSAGES + 1+ MAX_NUM_RECENT_UNREAD_MESSAGES : MAX_NUM_RECENT_UNREAD_MESSAGES + 1])self.assertGreater(len(older_messages), 0)@@ -922,7 +922,7 @@ class LoginTest(ZulipTestCase):# Make sure there's at least one recent message to be mark# unread. This prevents a bug where this test would start# failing the test database was generated more than- # ONBOARDING_RECENT_TIMEDELTA ago.+ # RECENT_MESSAGES_TIMEDELTA ago.self.subscribe(hamlet, "stream_0")self.send_stream_message(hamlet,