Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
digest: Rename get_recent_streams for clarity.
Alex Vandiverbca9821c892e
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.pyindex aeda16743be..9a67b867dc6 100644--- a/zerver/lib/digest.py+++ b/zerver/lib/digest.py@@ -215,20 +215,20 @@ def get_hot_topics(return hot_topics-def get_recent_streams(realm: Realm, threshold: datetime.datetime) -> List[Stream]:+def get_recently_created_streams(realm: Realm, threshold: datetime.datetime) -> List[Stream]:fields = ["id", "name", "is_web_public", "invite_only"]return list(get_active_streams(realm).filter(date_created__gt=threshold).only(*fields))def gather_new_streams(realm: Realm,- recent_streams: List[Stream], # streams only need id and name+ recently_created_streams: List[Stream], # streams only need id and namecan_access_public: bool,) -> Tuple[int, Dict[str, List[str]]]:if can_access_public:- new_streams = [stream for stream in recent_streams if not stream.invite_only]+ new_streams = [stream for stream in recently_created_streams if not stream.invite_only]else:- new_streams = [stream for stream in recent_streams if stream.is_web_public]+ new_streams = [stream for stream in recently_created_streams if stream.is_web_public]base_url = f"{realm.uri}/#narrow/stream/"@@ -337,7 +337,7 @@ def bulk_get_digest_context(stream_map = get_slim_stream_map(all_stream_ids)- recent_streams = get_recent_streams(realm, cutoff_date)+ recently_created_streams = get_recently_created_streams(realm, cutoff_date)for user in users:stream_ids = user_stream_map[user.id]@@ -358,7 +358,7 @@ def bulk_get_digest_context(# Gather new streams.new_streams_count, new_streams = gather_new_streams(realm=realm,- recent_streams=recent_streams,+ recently_created_streams=recently_created_streams,can_access_public=user.can_access_public_streams(),)context["new_streams"] = new_streamsdiff --git a/zerver/tests/test_digest.py b/zerver/tests/test_digest.pyindex 0ddf0e51ecd..5f5d44772fc 100644--- a/zerver/tests/test_digest.py+++ b/zerver/tests/test_digest.py@@ -18,7 +18,7 @@ from zerver.lib.digest import (enqueue_emails,gather_new_streams,get_hot_topics,- get_recent_streams,+ get_recently_created_streams,get_user_stream_map,)from zerver.lib.message import get_last_message_id@@ -463,9 +463,9 @@ class TestDigestEmailMessages(ZulipTestCase):realm = cordelia.realm- recent_streams = get_recent_streams(realm, cutoff)+ recently_created_streams = get_recently_created_streams(realm, cutoff)stream_count, stream_info = gather_new_streams(- realm, recent_streams, can_access_public=True+ realm, recently_created_streams, can_access_public=True)self.assertEqual(stream_count, 1)expected_html = f"<a href='http://zulip.testserver/#narrow/stream/{stream.id}-New-stream'>New stream</a>"@@ -473,7 +473,7 @@ class TestDigestEmailMessages(ZulipTestCase):# guests don't see our streamstream_count, stream_info = gather_new_streams(- realm, recent_streams, can_access_public=False+ realm, recently_created_streams, can_access_public=False)self.assertEqual(stream_count, 0)self.assertEqual(stream_info["html"], [])@@ -482,9 +482,9 @@ class TestDigestEmailMessages(ZulipTestCase):stream.is_web_public = Truestream.save()- recent_streams = get_recent_streams(realm, cutoff)+ recently_created_streams = get_recently_created_streams(realm, cutoff)stream_count, stream_info = gather_new_streams(- realm, recent_streams, can_access_public=True+ realm, recently_created_streams, can_access_public=True)self.assertEqual(stream_count, 1)@@ -492,9 +492,9 @@ class TestDigestEmailMessages(ZulipTestCase):stream.date_created = timezone_now() - datetime.timedelta(days=7)stream.save()- recent_streams = get_recent_streams(realm, cutoff)+ recently_created_streams = get_recently_created_streams(realm, cutoff)stream_count, stream_info = gather_new_streams(- realm, recent_streams, can_access_public=True+ realm, recently_created_streams, can_access_public=True)self.assertEqual(stream_count, 0)self.assertEqual(stream_info["html"], [])