message_flags: Fix accidentally quadratic behavior.

This commit is contained in:
Tim Abbott 2022-11-02 21:05:24 -07:00
parent d9dde2b4d9
commit 873ab01c7a
1 changed files with 2 additions and 2 deletions

View File

@ -272,7 +272,7 @@ def do_update_message_flags(
# currently subscribed to.
subscribed_recipient_ids = get_subscribed_stream_recipient_ids_for_user(user_profile)
message_ids_in_unsubscribed_streams = (
message_ids_in_unsubscribed_streams = set(
Message.objects.select_related("recipient")
.filter(id__in=messages, recipient__type=Recipient.STREAM)
.exclude(recipient_id__in=subscribed_recipient_ids)
@ -282,7 +282,7 @@ def do_update_message_flags(
messages = [
message_id
for message_id in messages
if message_id not in set(message_ids_in_unsubscribed_streams)
if message_id not in message_ids_in_unsubscribed_streams
]
query = UserMessage.select_for_update_query().filter(