mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user