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.

digest: Narrow the query by only fetching the sender full name.

Alex Vandiverd8668ab24212
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py
index 24c3863fe61..d7ddb424912 100644
--- a/zerver/lib/digest.py
+++ b/zerver/lib/digest.py
@@ -175,6 +175,11 @@ def get_recent_topics(
"sender", # we need the sender's full name
"sending_client", # for Message.sent_by_human
)
+ .defer(
+ # This construction, to only fetch the sender's full_name,
+ # is because `.only()` doesn't work with select_related tables.
+ *{f"sender__{f.name}" for f in UserProfile._meta.fields if f.name not in {"full_name"}}
+ )
)
digest_topic_map: Dict[TopicKey, DigestTopic] = {}