Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

export-search: Prefetch message sender.

Alex Vandiverae090d9ff3e6
diff --git a/zerver/management/commands/export_search.py b/zerver/management/commands/export_search.py
index 26723996922..a5aa0d6018f 100644
--- a/zerver/management/commands/export_search.py
+++ b/zerver/management/commands/export_search.py
@@ -201,7 +201,11 @@ This is most often used for legal compliance.
limits &= Q(recipient__in=[s.recipient_id for s in channels])
attachments_written: set[str] = set()
- messages_query = Message.objects.filter(limits, realm=realm).order_by("date_sent")
+ messages_query = (
+ Message.objects.filter(limits, realm=realm)
+ .select_related("sender")
+ .order_by("date_sent")
+ )
print(f"Exporting {len(messages_query)} messages...")
@lru_cache(maxsize=1000)