Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
delete_in_topic: Don't fetch .recipient for each message in a loop.
Mateusz Manderaf119c3378981
diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex 7a2a950a351..cb96bc5130a 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -1323,8 +1323,10 @@ def delete_in_topic(if time.monotonic() >= start_time + 50:return json_success(request, data={"complete": False})with transaction.atomic(durable=True):- messages_to_delete = messages.order_by("-id")[0:batch_size].select_for_update(- of=("self",)+ messages_to_delete = (+ messages.select_related("recipient")+ .order_by("-id")[0:batch_size]+ .select_for_update(of=("self",)))if not messages_to_delete:break