Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
digest: Rename get_slim_stream_map slightly and explain its name more.
Alex Vandiverf8a9779b5475
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.pyindex 9a67b867dc6..f9979b7b5fb 100644--- a/zerver/lib/digest.py+++ b/zerver/lib/digest.py@@ -64,12 +64,12 @@ class DigestTopic:def diversity(self) -> int:return len(self.human_senders)- def teaser_data(self, user: UserProfile, stream_map: Dict[int, Stream]) -> Dict[str, Any]:+ def teaser_data(self, user: UserProfile, stream_id_map: Dict[int, Stream]) -> Dict[str, Any]:teaser_count = self.num_human_messages - len(self.sample_messages)first_few_messages = build_message_list(user=user,messages=self.sample_messages,- stream_map=stream_map,+ stream_id_map=stream_id_map,)return {"participants": sorted(self.human_senders),@@ -298,8 +298,9 @@ def get_user_stream_map(user_ids: List[int], cutoff_date: datetime.datetime) ->return dct-def get_slim_stream_map(stream_ids: Set[int]) -> Dict[int, Stream]:- # This can be passed to build_message_list.+def get_slim_stream_id_map(stream_ids: Set[int]) -> Dict[int, Stream]:+ # "slim" because it only fetches the names of the stream objects,+ # suitable for passing into build_message_list.streams = Stream.objects.filter(id__in=stream_ids,).only("id", "name")@@ -335,7 +336,7 @@ def bulk_get_digest_context(# for each user, we filter to just the streams they care about.recent_topics = get_recent_topics(realm.id, sorted(all_stream_ids), cutoff_date)- stream_map = get_slim_stream_map(all_stream_ids)+ stream_id_map = get_slim_stream_id_map(all_stream_ids)recently_created_streams = get_recently_created_streams(realm, cutoff_date)@@ -352,7 +353,7 @@ def bulk_get_digest_context(# Get context data for hot conversations.context["hot_conversations"] = [- hot_topic.teaser_data(user, stream_map) for hot_topic in hot_topics+ hot_topic.teaser_data(user, stream_id_map) for hot_topic in hot_topics]# Gather new streams.diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.pyindex d7d445ae5bc..406d1f76912 100644--- a/zerver/lib/email_notifications.py+++ b/zerver/lib/email_notifications.py@@ -195,7 +195,7 @@ def add_quote_prefix_in_text(content: str) -> str:def build_message_list(user: UserProfile,messages: List[Message],- stream_map: Dict[int, Stream], # only needs id, name+ stream_id_map: Dict[int, Stream], # only needs id, name) -> List[Dict[str, Any]]:"""Builds the message list object for the message notification email template.@@ -280,7 +280,7 @@ def build_message_list(assert message.recipient.type == Recipient.STREAMgrouping = {"stream": message.recipient_id, "topic": message.topic_name().lower()}stream_id = message.recipient.type_id- stream = stream_map.get(stream_id, None)+ stream = stream_id_map.get(stream_id, None)if stream is None:# Some of our callers don't populate stream_map, so# we just populate the stream from the database.