mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
digest: Directly fetch recipient ids from the DB.
Instead of iterating over Subscriptions and creating the list of home view recipients, the query now only fetches recipient IDs from the DB.
This commit is contained in:
committed by
Tim Abbott
parent
94649f58f2
commit
cb5e9107f4
@@ -230,11 +230,10 @@ def handle_digest_email(user_profile_id: int, cutoff: float,
|
||||
user_profile, [pm.message for pm in pms[:pms_limit]])
|
||||
context['remaining_unread_pms_count'] = max(0, len(pms) - pms_limit)
|
||||
|
||||
home_view_recipients = [sub.recipient for sub in
|
||||
Subscription.objects.filter(
|
||||
user_profile=user_profile,
|
||||
active=True,
|
||||
in_home_view=True)]
|
||||
home_view_recipients = Subscription.objects.filter(
|
||||
user_profile=user_profile,
|
||||
active=True,
|
||||
in_home_view=True).values_list('recipient_id', flat=True)
|
||||
|
||||
stream_messages = all_messages.filter(
|
||||
message__recipient__type=Recipient.STREAM,
|
||||
|
||||
@@ -121,7 +121,7 @@ class TestDigestEmailMessages(ZulipTestCase):
|
||||
with queries_captured() as queries:
|
||||
handle_digest_email(othello.id, cutoff)
|
||||
|
||||
self.assertTrue(29 <= len(queries) <= 30)
|
||||
self.assertTrue(24 <= len(queries) <= 25)
|
||||
|
||||
self.assertEqual(mock_send_future_email.call_count, 1)
|
||||
kwargs = mock_send_future_email.call_args[1]
|
||||
|
||||
Reference in New Issue
Block a user