digest: Pass length of hot_conversations to enough_traffic function.

Previously, `hot_conversations` was incorrectly passed as a string to the
`enough_traffic` function. This commit fixes the issue by passing the length
of `hot_conversations` as a parameter instead.
This commit is contained in:
opmkumar
2025-04-04 11:16:03 +05:30
committed by Tim Abbott
parent c40bd39a01
commit ec81c027fc
2 changed files with 3 additions and 3 deletions

View File

@@ -268,7 +268,7 @@ def gather_new_streams(
return len(new_streams), {"html": channels_html, "plain": channels_plain}
def enough_traffic(hot_conversations: str, new_streams: int) -> bool:
def enough_traffic(hot_conversations: int, new_streams: int) -> bool:
return bool(hot_conversations or new_streams)
@@ -400,7 +400,7 @@ def bulk_handle_digest_email(user_ids: list[int], cutoff: float) -> None:
for user, context in bulk_get_digest_context(users, cutoff):
# We don't want to send emails containing almost no information.
if not enough_traffic(context["hot_conversations"], context["new_streams_count"]):
if not enough_traffic(len(context["hot_conversations"]), context["new_streams_count"]):
continue
digest_users.append(user)

View File

@@ -144,7 +144,7 @@ class TestDigestEmailMessages(ZulipTestCase):
) as enough_traffic_mock:
bulk_handle_digest_email([othello.id], in_the_future)
mock_send_future_email.assert_called()
enough_traffic_mock.assert_called_once_with([], 0)
enough_traffic_mock.assert_called_once_with(0, 0)
@mock.patch("zerver.lib.digest.enough_traffic")
@mock.patch("zerver.lib.digest.send_future_email")