From d55240e5430adbf1bb0a9c6d0b4a945462c7df0f Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 27 Sep 2023 16:17:41 +0000 Subject: [PATCH] topic: Add comments calling out case-sensitive index usage. --- zerver/lib/topic.py | 6 ++++++ zerver/models.py | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/zerver/lib/topic.py b/zerver/lib/topic.py index fba2833e1a..4801cbff9e 100644 --- a/zerver/lib/topic.py +++ b/zerver/lib/topic.py @@ -226,6 +226,9 @@ def generate_topic_history_from_db_rows(rows: List[Tuple[str, int]]) -> List[Dic def get_topic_history_for_public_stream(realm_id: int, recipient_id: int) -> List[Dict[str, Any]]: cursor = connection.cursor() + # Uses index: zerver_message_realm_recipient_subject + # Note that this is *case-sensitive*, so that we can display the + # most recently-used case (in generate_topic_history_from_db_rows) query = """ SELECT "zerver_message"."subject" as topic, @@ -254,6 +257,9 @@ def get_topic_history_for_stream( return get_topic_history_for_public_stream(user_profile.realm_id, recipient_id) cursor = connection.cursor() + # Uses index: zerver_message_realm_recipient_subject + # Note that this is *case-sensitive*, so that we can display the + # most recently-used case (in generate_topic_history_from_db_rows) query = """ SELECT "zerver_message"."subject" as topic, diff --git a/zerver/models.py b/zerver/models.py index 813554008c..f91a4c337d 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -3175,7 +3175,9 @@ class Message(AbstractMessage): name="zerver_message_realm_recipient_upper_subject", ), models.Index( - # Only used by already_sent_mirrored_message_id + # Used by already_sent_mirrored_message_id, and when + # determining recent topics (we post-process to merge + # and show the most recent case) "realm_id", "recipient_id", "subject",