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.

minor: Add order-by-id to digest message query.

Steve Howell5da433262004
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py
index ffb51440623..2de9bb2038c 100644
--- a/zerver/lib/digest.py
+++ b/zerver/lib/digest.py
@@ -129,7 +129,14 @@ def get_recent_topics(
messages = Message.objects.filter(
recipient__type=Recipient.STREAM,
recipient__type_id__in=stream_ids,
- date_sent__gt=cutoff_date).select_related('recipient', 'sender', 'sending_client')
+ date_sent__gt=cutoff_date,
+ ).order_by(
+ 'id', # we will sample the first few messages
+ ).select_related(
+ 'recipient', # we need stream_id
+ 'sender', # we need the sender's full name
+ 'sending_client' # for Message.sent_by_human
+ )
digest_topic_map: Dict[TopicKey, DigestTopic] = {}
for message in messages: