export-search: Limit to only the fields we need.

(cherry picked from commit e9c6856d02)
This commit is contained in:
Alex Vandiver
2025-08-22 03:37:14 +00:00
committed by Tim Abbott
parent 270a19984a
commit a9417eb4fe

View File

@@ -204,6 +204,17 @@ This is most often used for legal compliance.
messages_query = (
Message.objects.filter(limits, realm=realm)
.select_related("sender")
.only(
"id",
"date_sent",
"sender__full_name",
"sender__delivery_email",
"recipient_id",
"subject",
"content",
"edit_history",
"has_attachment",
)
.order_by("date_sent")
)
print(f"Exporting {len(messages_query)} messages...")